Search results for

[tags:wwdc20-10057]

16 results found

Post

Replies

Boosts

Views

Activity

OutlineGroup and hierarchical List with Core Data
Given a NSManagedObject like below: public class Folder: NSManagedObject, Identifiable { t@NSManaged public var name: String t@NSManaged public var position: Int16 t@NSManaged public var parentFolder: Folder? t@NSManaged public var folders: Set<Folder> } I'd like to use the new OutlineGroup to build an outline view of the folder structure using a FetchRequest. struct FolderView { @FetchRequest(entity: Folder.entity(), tttttttsortDescriptors: [NSSortDescriptor(keyPath: Folder.position, ascending: true)]) var folders: FetchResults<Folder> tvar body: some View { ttOutlineGroup(folders, children: .folders) { folder in tttLabel(folder.name, systemImage: folder.fill) t} But this doesn't compile, with the following error: Key path value type 'Set<Folder>' cannot be converted to contextual type 'FetchedResults<Folder>?' Any idea? As a bonus, the children should also be ordered by the position (because it's a Set, it's unordered)…
7
0
2.9k
Oct ’20
What are the downsides to using lazy stacks?
In Stacks, Grids, and Outlines in SwiftUI - https://developer.apple.com/videos/play/wwdc2020/10031, a recommendation is made to only use lazy stacks when you encounter performance bottlenecks. To quote the session, starting at 4:43: On the other hand, making the stacks within a given hero view lazy doesn't actually confer any benefits. The content is all visible at once, as soon as the view lands on screen. So everything has to be loaded at once, regardless of the container's default behavior. If you aren't sure which stack to use, use VStack or HStack. Adopt lazy stacks as a way to resolve performance bottlenecks that you find after profiling with Instruments. Are there negatives, performance or otherwise, to just always use lazy stacks? I'd like to understand why I shouldn't reach for LazyVStack and LazyHStack first. I understand from the example that using a lazy stack wouldn't confer any benefits, but would we incur any negatives?
3
0
8.9k
Aug ’20
How to get collapsable sections as shown in 'Stacks, Grids, and Outlines in SwiftUI'?
I tried to replicate the code as shown in Stacks, Grids, and Outlines in SwiftUI - https://developer.apple.com/videos/play/wwdc2020/10031/ (12:35). They make it feel like it's a very easy thing to do. Just insert a Section and as you could see in the video it will immediately become a collapsable view. Add a header to the section and it will get the bolder text style. I wasn't able to replicate this. xCode Version 12.0 beta (12A6159) Below you can find the code I used. The expected result would be nicely styled, collapsable section headers. The actual result is a non-collapsable section with a weird underline under the name and no arrow. let model: Model = Model() @State private var selection: Set<String> = [] var body: some View { NavigationView { List(selection: $selection) { ForEach(model.canvases) { canvas in Section(header: Text(canvas.name)) { OutlineGroup(canvas.graphics, children: .children) { graphic in Label(graphic.name, systemImage: graphic.icon) } } } } .listStyle(SidebarListStyle()) .navig
3
0
4.3k
Jul ’20
WWDC talk says we can "download the code for ShapeEdit" but there doesn't appear to be a download link?
At the very end of the Stacks, Grids, and Outlines in SwiftUI talk we're told we Experiment with the code for ShapeEdit on the last slide and the presenter says we can download the code for ShapeEdit from developer.apple.com. However I cannot see a link to download on the video's page https://developer.apple.com/wwdc20/10031 , and I cannot see it on the sample code page on the developer site. Would someone at Apple be able to upload this code? Or if it's already available can anyone here show me where to download? many thanks!
2
0
900
Jul ’20
SwiftUI Picker with Multiple Selection
Hi! One of my main frustrations with SwiftUI last WWDC was the apparent lack of a View allowing for multiple selections. This year's Stacks, Grids and Outlines in SwiftUI Session even shows a brief snippet with @Binding private var selection: Set<String> which would indicate the possibility of multiple selections with a Picker view in SwiftUI. However the sample code for the app presented there is not available... In short: how should one use Picker or go about creating another view which would allow multiple selections? To stay in the Sandwiches theme of this year's apps: how would one create a Picker allowing selection of multiple ingredients from a list?
3
0
11k
Jun ’20
Use Lazy Stack or Regular Stack in ScrollView?
A few of us were discussing the advice for when to use Lazy Stacks in this session, specifically where Cody Brimhall said the following: So it's worth asking, since I made my outer stack lazy, should these stacks be lazy too? In this case, the answer is no. While I want the vertical stack to be lazy specifically because it scrolls, I don't want to spend the time it takes to render everything upfront when most of the content can't be seen without scrolling. On the other hand, making the stacks within a given hero view lazy doesn't actually confer any benefits. The content is all visible at once as soon as the view lands on screen, so everything has to be loaded at once regardless of the container's default behavior. As a rule, if you aren't sure which type of stack to use, use VStack or HStack. Adopt lazy stacks as a way to resolve performance bottlenecks that you find after profiling with instruments. The earlier advice seems to suggest that using a Lazy Stack in a ScrollView is preferred. That rule of thumb
0
0
682
Jun ’20
Can you span multiple columns or rows in a grid?
Is there a way for a view to span multiple columns or rows when using LazyVGrid or LazyHGrid? I'm trying to make a calendar and would like to have a row that is the month and year label. I've tried using several LazyVGrid in a LazyVStack, but the scrolling performance seemed pretty poor, so I'm trying to see if I can make a single LazyVGrid work.
0
0
812
Jun ’20