Post

Replies

Boosts

Views

Activity

Swift UI TableColumn with Int data
I was playing around with TableColumn api in MacOS Ventura I have the following data model. actor HousingData: Identifiable {     let id: Int     let rank: Int     let region: String     let regionType: RegionType     let state: String } However when it try to do TableColumn("foo", value: \.rank) I get Key path value type 'Int' cannot be converted to contextual type 'String' if I try TableColumn("Rank", value: \.rank) { rank in Text("\(rank)") } I get Referencing initializer 'init(_:value:content:)' on 'TableColumn' requires the types 'Never' and 'KeyPathComparator<HousingData>' be equivalent If i use a string value all works well.
4
0
3.2k
Mar ’23
Dynamic TableColumns with ForEach
There seems to be no way to add dynamically add table columns to SwfitUI table. I have a column of dates that I store in an array like so. let dates = [Date] let values = [Int] I want one able enumerate over the dates to generate columns. However I can't seem to find a way to enumerate over them and generate my columns. My current data set has 250 columns and it will keep growing. I would love to do ForEach(0 ..< dates.length) { index in TableColumn("<some formatted date>") { Text("\(value)") } } But it appears that since TableColumn is not a view ForEach can't be used. Is there a supported way to build columns dynamically? This is a Mac application. Does charts support a for each type symantic too?
0
0
1.3k
Jun ’22
Regex code from WWDC sample code not working
If I past the samele code import RegexBuilder let fieldSeparator = /\s{2,}|\t/ let transactionMatcher = Regex { /CREDIT|DEBIT/ fieldSeparator One(.date(.numeric, locale: Locale(identifier: "en_US"), timeZone: .gmt)) fieldSeparator OneOrMore { NegativeLookahead { fieldSeparator } CharacterClass.any } fieldSeparator One(.localizedCurrency(code: "USD").locale(Locale(identifier: "en_US"))) } It does not like the OneOrMore with the negative look ahead. Is there an updated example of this code from WWDC?
1
1
1.3k
Jun ’22
LazyVStack child disappears off screen before its off screen.
I have a scroll view with one item in it. When is scroll it under a the navigation bar it disappears before the whole cell is gone it seems to be about when ½ the cell is disappeared. Simple LazyVStack   NavigationView {   ZStack {     ScrollView {       LazyVStack {             ForEach(model.wallets, id: \.id) { wallet in                 GalleryCell(wallet: wallet)               }       }        }   }
0
1
1.1k
Nov ’21
Swift UI TableColumn with Int data
I was playing around with TableColumn api in MacOS Ventura I have the following data model. actor HousingData: Identifiable {     let id: Int     let rank: Int     let region: String     let regionType: RegionType     let state: String } However when it try to do TableColumn("foo", value: \.rank) I get Key path value type 'Int' cannot be converted to contextual type 'String' if I try TableColumn("Rank", value: \.rank) { rank in Text("\(rank)") } I get Referencing initializer 'init(_:value:content:)' on 'TableColumn' requires the types 'Never' and 'KeyPathComparator<HousingData>' be equivalent If i use a string value all works well.
Replies
4
Boosts
0
Views
3.2k
Activity
Mar ’23
Dynamic TableColumns with ForEach
There seems to be no way to add dynamically add table columns to SwfitUI table. I have a column of dates that I store in an array like so. let dates = [Date] let values = [Int] I want one able enumerate over the dates to generate columns. However I can't seem to find a way to enumerate over them and generate my columns. My current data set has 250 columns and it will keep growing. I would love to do ForEach(0 ..< dates.length) { index in TableColumn("<some formatted date>") { Text("\(value)") } } But it appears that since TableColumn is not a view ForEach can't be used. Is there a supported way to build columns dynamically? This is a Mac application. Does charts support a for each type symantic too?
Replies
0
Boosts
0
Views
1.3k
Activity
Jun ’22
Regex code from WWDC sample code not working
If I past the samele code import RegexBuilder let fieldSeparator = /\s{2,}|\t/ let transactionMatcher = Regex { /CREDIT|DEBIT/ fieldSeparator One(.date(.numeric, locale: Locale(identifier: "en_US"), timeZone: .gmt)) fieldSeparator OneOrMore { NegativeLookahead { fieldSeparator } CharacterClass.any } fieldSeparator One(.localizedCurrency(code: "USD").locale(Locale(identifier: "en_US"))) } It does not like the OneOrMore with the negative look ahead. Is there an updated example of this code from WWDC?
Replies
1
Boosts
1
Views
1.3k
Activity
Jun ’22
LazyVStack child disappears off screen before its off screen.
I have a scroll view with one item in it. When is scroll it under a the navigation bar it disappears before the whole cell is gone it seems to be about when ½ the cell is disappeared. Simple LazyVStack   NavigationView {   ZStack {     ScrollView {       LazyVStack {             ForEach(model.wallets, id: \.id) { wallet in                 GalleryCell(wallet: wallet)               }       }        }   }
Replies
0
Boosts
1
Views
1.1k
Activity
Nov ’21