我的职业选择
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了我的职业选择相关的知识,希望对你有一定的参考价值。
参考技术A 这几天,和小包子、小雨、贝贝都讨论过职业方向问题,这让我也认真地思考了一下我自己,企业做得好好的,整天投入那么多精力“不务正业”,正确吗?结论是:非常正确!
职业的选择无非分三种:
必须做;
愿意做;
必须而且愿意做。
我现在的职业是历史的选择,是必须做的,因为那是作为一个男人所有责任的承载体,更是马斯洛所言人的五个需求层次的保障,必须做好!当然,就像夫妻,相处久了,也就慢慢喜欢上它了,但却不是我的终极人生目标。
十年前,我给自己一生确定的目标是“快乐一生,伟大一生,渡己渡人”,最近我又根据古典老师的提法,在原来基础上增加了一句“用持续有成就感的方式过一生”。“渡己渡人”是我“成就感”所在,若要做到“渡己渡人”,从灵魂、从认知、从价值观等方向上去努力应该是最为简洁的路径。而类似罗胖、樊登、万维钢、古典、甚至叶武斌这些人就是我的榜样。当我以他们为标杆如饥似渴的学习知识、提高认知、交友畅言时,特别有激情,特别有力量,特别快乐和愉悦,我仿佛已经找到了实现人生终极目标的微弱灯塔。
所以,“不务正业”非常正确之一就是它是我喜欢做的事,愿意做的事,是向着我自己理想国前进的正确道路。
“不务正业”非常正确原因之二是反脆弱。
世界是脆弱的,我们的世界并不坚固,相反它非常脆弱。天灾人祸、生老病死,时刻都在发生,而我们总是无能为力。对于我们商业界,据统计,中国中小企业的平均寿命仅2.5年,集团企业的平均寿命仅7-8年,每年倒闭的企业有100万家之多。企业的生命脆弱如纸!
脆弱如此可怕,那么,脆弱的反面是什么?是坚强、坚韧吗?
脆弱的反面并不是坚强或坚韧。坚强或坚韧只是保证一个事物在不确定性中不受伤或保持不变,却没有办法更进一步,让自己变得更好。而脆弱的反面应该完成这个步骤,不仅在风险中保全自我,而且变得更好、更有力量。做一个类比的话,坚强或坚韧就像一个被扔到地上的纸团,不会摔坏,但是也只是维持了原貌,这还不够。和纸团相反,乒乓球扔到地上非但不会摔坏,而且借势积聚了能量,反而可以弹得更高。乒乓球拥有的就是脆弱反面的能力,也就是反脆弱。反脆弱是塔勒布定义的一个全新概念,和脆弱刚好相反,指向了另一个方向,指出事物在风险和不确定性面前并不是束手无策的,完全可以扭亏为盈。这也就是“反脆弱”能力的精髓:在不确定性中获益,变得更好。在我们个体对职业的选择时,反脆弱的最有效策略就是“杠铃型职业设计”。
简而言之,就是要学会做多手准备,合理分配自己的时间、精力、资源,在杠铃的两头都有储备,避免满盘皆输的局面,通俗点说就是“鸡蛋别放在一个篮子里”。比如我要全力以赴做好现在的企业,但也要非常清楚企业、行业都是有寿命周期的,必须未雨绸缪,跟上时代和趋势,始终占据时代的风口。比如友哥,除了做好公务员的工作外,必须看见外面的世界五彩纷呈,还需做好随时潇洒走一回的基础准备。
在实际操作中,利用好杠铃策略,要求我们有全局思考的能力,不盲目自信、也不贸然行事。诸如“卖房创业”这样的举动是冒险的,也降低了自身的反脆弱能力。
“不务正业”非常正确原因之三是“正业”与“不正业”相辅相成,相得益彰。
我现在的企业像航行在大海中的轮船,随时都会遇到各种各样的挑战,作为舵手的我,必须具备航海家的所有知识和经验能力,那如何才能成为一个这样的舵手呢?必须学习,必须如饥似渴的学习,而学习最有效的方式就是输入—输出—刻意练习,“不正业”刚好就是做这个的!而学到的知识只有在实践中应用才能不断反思、总结,形成牢固的知识晶体。“正业”与“不正业”之间的哑铃连接杆使二者密不可分,浑然一体。
所以,没有“不正业”,恰恰是正确的选择!
为啥我的 SwiftUI 列表选择在选择时没有突出显示?
【中文标题】为啥我的 SwiftUI 列表选择在选择时没有突出显示?【英文标题】:Why is my SwiftUI List selection not highlighting when selected?为什么我的 SwiftUI 列表选择在选择时没有突出显示? 【发布时间】:2021-07-21 06:57:51 【问题描述】:我知道代码不是最漂亮的,我仍在学习如何压缩代码并减少诸如排序列表的方式所需的行数。但是,我确实需要帮助来试图弄清楚为什么这个列表没有在选中的任何行上显示突出显示。作为参考,我放了一个打印语句来验证水龙头是否在行上注册,并且工作正常。
一些进一步的信息:该行的“onDelete”操作正在删除错误的行。也许这与选择有关?任何建议都会很棒。
//
// TableView.swift
// TableDemo (iOS)
//
// Created by Kyle Carroll on 7/20/21.
//
//TODO: Delete at "index set" is deleting wrong row
//TODO: Row selection not working
import SwiftUI
struct TableView: View
@StateObject var bookStore : BookStore = BookStore(books:bookData)
@State var sortBy: String = ""
@State var IDbuttonStatus: IDButtonStatus = .firstPress
@State var titleButtonStatus: TitleButtonStatus = .firstPress
@State var authorButtonStatus: AuthorButtonStatus = .firstPress
@State var pagesButtonStatus: PagesButtonStatus = .firstPress
enum IDButtonStatus
case secondPress
case firstPress
var nextStatus: IDButtonStatus
switch self
case .firstPress: return .secondPress
case .secondPress: return .firstPress
var order: String
switch self
case .firstPress: return "id2"
case .secondPress: return "id"
enum TitleButtonStatus
case firstPress
case secondPress
var nextStatus: TitleButtonStatus
switch self
case .firstPress: return .secondPress
case .secondPress: return .firstPress
var order: String
switch self
case .firstPress: return "title2"
case .secondPress: return "title"
enum AuthorButtonStatus
case firstPress
case secondPress
var nextStatus: AuthorButtonStatus
switch self
case .firstPress: return .secondPress
case .secondPress: return .firstPress
var order: String
switch self
case .firstPress: return "author2"
case .secondPress: return "author"
enum PagesButtonStatus
case firstPress
case secondPress
var nextStatus: PagesButtonStatus
switch self
case .firstPress: return .secondPress
case .secondPress: return .firstPress
var order: String
switch self
case .firstPress: return "pages2"
case .secondPress: return "pages1"
var body: some View
VStack
HStack(alignment: .center, spacing: nil)
HStack
Text("ID")
Button
IDbuttonStatus = IDbuttonStatus.nextStatus
self.sortBy = IDbuttonStatus.order
label:
Image(systemName: "chevron.up.chevron.down")
.foregroundColor(Color.black)
.frame(maxWidth: 50, alignment: .leading)
Divider()
HStack
Text("Title")
Button
titleButtonStatus = titleButtonStatus.nextStatus
self.sortBy = titleButtonStatus.order
label:
Image(systemName: "chevron.up.chevron.down")
.foregroundColor(Color.black)
.frame(maxWidth: 200, alignment: .leading)
Divider()
HStack
Text("Author")
Button
authorButtonStatus = authorButtonStatus.nextStatus
self.sortBy = authorButtonStatus.order
label:
Image(systemName: "chevron.up.chevron.down")
.foregroundColor(Color.black)
.frame(maxWidth: 200, alignment: .leading)
Divider()
HStack
Text("Pages")
Button
pagesButtonStatus = pagesButtonStatus.nextStatus
self.sortBy = pagesButtonStatus.order
label:
Image(systemName: "chevron.up.chevron.down")
.foregroundColor(Color.black)
.frame(maxWidth: 75, alignment: .leading)
.frame(maxWidth: .infinity, maxHeight: 40, alignment: .leading)
.padding(.leading, 20)
List
switch self.sortBy
case "title":
ForEach (bookStore.books.sorted $0.title < $1.title) book in
ListCell(book: book)
.onDelete(perform: deleteItems)
case "title2":
ForEach (bookStore.books.sorted $0.title > $1.title) book in
ListCell(book: book)
case "id":
ForEach (bookStore.books.sorted $0.id < $1.id) book in
ListCell(book: book)
case "id2":
ForEach (bookStore.books.sorted $0.id > $1.id) book in
ListCell(book: book)
case "author":
ForEach (bookStore.books.sorted $0.authorsort < $1.authorsort) book in
ListCell(book: book)
case "author2":
ForEach (bookStore.books.sorted $0.authorsort > $1.authorsort) book in
ListCell(book: book)
case "pages":
ForEach (bookStore.books.sorted $0.pages < $1.pages) book in
ListCell(book: book)
case "pages2":
ForEach (bookStore.books.sorted $0.pages > $1.pages) book in
ListCell(book: book)
default:
ForEach (bookStore.books.sorted $0.id < $1.id) book in
ListCell(book: book)
.listStyle(PlainListStyle())
.frame(maxWidth: .infinity, alignment: .leading)
func deleteItems(at offsets: IndexSet)
bookStore.books.remove(atOffsets: offsets)
struct ListCell: View
var book : Book
var body: some View
HStack(alignment: .center, spacing: nil)
Text("\(book.id)")
.frame(maxWidth: 50, alignment: .leading)
Divider()
Text(book.title)
.frame(maxWidth: 200, alignment: .leading)
Divider()
Text(book.author)
.frame(maxWidth: 200, alignment: .leading)
Divider()
Text("\(book.pages)")
.frame(maxWidth: 75, alignment: .leading)
.onTapGesture
print(book.title)
struct TableView_Previews: PreviewProvider
static var previews: some View
if #available(iOS 15.0, *)
TableView()
.previewInterfaceOrientation(.landscapeLeft)
else
// Fallback on earlier versions
【问题讨论】:
你的代码很长。您能否将其缩短为 Minimal Reproducable Example ™ (***.com/help/minimal-reproducible-example)? 也就是说,我扫描了您的代码,找不到与选择或突出显示相关的任何内容。 SwiftUI 不会开箱即用地为您执行此操作,您必须手动跟踪所选行(索引),并自己突出显示它。 【参考方案1】:“...为什么这个列表没有在任何被选中的行上显示突出显示。” 我不确定,但它很容易修复。查看测试代码。
类似地,“...该行的“onDelete”操作正在删除错误的行。” 您必须对正文中的书籍列表进行排序,以获得要删除的正确索引。 你需要做一些工作。
这是我用来测试和帮助你的代码:
import SwiftUI
@main
struct TestApp: App
var body: some Scene
WindowGroup
ContentView()
struct TableView: View
@StateObject var bookStore : BookStore = BookStore() // <--- for testing
@State var sortBy: String = ""
@State var IDbuttonStatus: IDButtonStatus = .firstPress
@State var titleButtonStatus: TitleButtonStatus = .firstPress
@State var authorButtonStatus: AuthorButtonStatus = .firstPress
@State var pagesButtonStatus: PagesButtonStatus = .firstPress
@State var selectedBook: Book? = nil // <---- here
enum IDButtonStatus
case secondPress
case firstPress
var nextStatus: IDButtonStatus
switch self
case .firstPress: return .secondPress
case .secondPress: return .firstPress
var order: String
switch self
case .firstPress: return "id2"
case .secondPress: return "id"
enum TitleButtonStatus
case firstPress
case secondPress
var nextStatus: TitleButtonStatus
switch self
case .firstPress: return .secondPress
case .secondPress: return .firstPress
var order: String
switch self
case .firstPress: return "title2"
case .secondPress: return "title"
enum AuthorButtonStatus
case firstPress
case secondPress
var nextStatus: AuthorButtonStatus
switch self
case .firstPress: return .secondPress
case .secondPress: return .firstPress
var order: String
switch self
case .firstPress: return "author2"
case .secondPress: return "author"
enum PagesButtonStatus
case firstPress
case secondPress
var nextStatus: PagesButtonStatus
switch self
case .firstPress: return .secondPress
case .secondPress: return .firstPress
var order: String
switch self
case .firstPress: return "pages2"
case .secondPress: return "pages1"
var body: some View
VStack
HStack(alignment: .center, spacing: nil)
HStack
Text("ID")
Button
IDbuttonStatus = IDbuttonStatus.nextStatus
self.sortBy = IDbuttonStatus.order
label:
Image(systemName: "chevron.up.chevron.down")
.foregroundColor(Color.black)
.frame(maxWidth: 50, alignment: .leading)
Divider()
HStack
Text("Title")
Button
titleButtonStatus = titleButtonStatus.nextStatus
self.sortBy = titleButtonStatus.order
label:
Image(systemName: "chevron.up.chevron.down")
.foregroundColor(Color.black)
.frame(maxWidth: 200, alignment: .leading)
Divider()
HStack
Text("Author")
Button
authorButtonStatus = authorButtonStatus.nextStatus
self.sortBy = authorButtonStatus.order
label:
Image(systemName: "chevron.up.chevron.down")
.foregroundColor(Color.black)
.frame(maxWidth: 200, alignment: .leading)
Divider()
HStack
Text("Pages")
Button
pagesButtonStatus = pagesButtonStatus.nextStatus
self.sortBy = pagesButtonStatus.order
label:
Image(systemName: "chevron.up.chevron.down")
.foregroundColor(Color.black)
.frame(maxWidth: 75, alignment: .leading)
.frame(maxWidth: .infinity, maxHeight: 40, alignment: .leading)
.padding(.leading, 20)
List
switch self.sortBy
case "title":
ForEach (bookStore.books.sorted $0.title < $1.title) book in
ListCell(book: book, selectedBook: $selectedBook) // <---- here
.onDelete(perform: deleteItems)
case "title2":
ForEach (bookStore.books.sorted $0.title > $1.title) book in
ListCell(book: book, selectedBook: $selectedBook) // <---- here
case "id":
ForEach (bookStore.books.sorted $0.id < $1.id) book in
ListCell(book: book, selectedBook: $selectedBook) // <---- here
case "id2":
ForEach (bookStore.books.sorted $0.id > $1.id) book in
ListCell(book: book, selectedBook: $selectedBook) // <---- here
case "author":
ForEach (bookStore.books.sorted $0.authorsort < $1.authorsort) book in
ListCell(book: book, selectedBook: $selectedBook) // <---- here
case "author2":
ForEach (bookStore.books.sorted $0.authorsort > $1.authorsort) book in
ListCell(book: book, selectedBook: $selectedBook) // <---- here
case "pages":
ForEach (bookStore.books.sorted $0.pages < $1.pages) book in
ListCell(book: book, selectedBook: $selectedBook) // <---- here
case "pages2":
ForEach (bookStore.books.sorted $0.pages > $1.pages) book in
ListCell(book: book, selectedBook: $selectedBook) // <---- here
default:
ForEach (bookStore.books.sorted $0.id < $1.id) book in
ListCell(book: book, selectedBook: $selectedBook) // <---- here
.listStyle(PlainListStyle())
.frame(maxWidth: .infinity, alignment: .leading)
func deleteItems(at offsets: IndexSet) // <---- here
// // must sort the bookStore.books as in the body
// let sortedList = ...
// // get the book from the sortedList
// let theBook = sortedList[offsets.first!]
// // get the index of theBook from the bookStore, and remove it
// if let ndx = bookStore.books.firstIndex(of: theBook)
// withAnimation
// bookStore.books.remove(at: ndx)
//
//
struct ListCell: View
var book : Book
@Binding var selectedBook: Book? // <---- here
var body: some View
HStack(alignment: .center, spacing: nil)
Text("\(book.id)")
.frame(maxWidth: 50, alignment: .leading)
Divider()
Text(book.title)
.frame(maxWidth: 200, alignment: .leading)
Divider()
Text(book.author)
.frame(maxWidth: 200, alignment: .leading)
Divider()
Text("\(book.pages)")
.frame(maxWidth: 75, alignment: .leading)
.background((selectedBook?.id ?? -1) == book.id ? Color.gray : Color.white) // <---- here
.onTapGesture
print(book.title)
selectedBook = book // <---- here
struct TableView_Previews: PreviewProvider
static var previews: some View
if #available(iOS 15.0, *)
TableView()
.previewInterfaceOrientation(.landscapeLeft)
else
// Fallback on earlier versions
struct Book: Identifiable, Hashable
var id : Int
var title : String
var pages : String
var authorsort : String
var author : String = "author"
class BookStore: ObservableObject
@Published var books: [Book] = [
Book(id: 1, title: "book1", pages: "page1", authorsort: "authorsort1"),
Book(id: 2, title: "book2", pages: "page2", authorsort: "authorsort2"),
Book(id: 3, title: "book3", pages: "page3", authorsort: "authorsort3")]
struct ContentView: View
var body: some View
TableView()
【讨论】:
完美。在你的例子和一些额外的研究之间,我能够让它工作。感谢您花时间浏览我的乱七八糟的代码!以上是关于我的职业选择的主要内容,如果未能解决你的问题,请参考以下文章
为啥我的 charFormat 样式仅适用于选择,并且仅适用于特定方向的选择?