UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Day 59 Core Data Wrap Up referencing enum inside subview

Forums > 100 Days of SwiftUI

This line gives me the error "Generic parameter 'Content' could not be inferred"

@State private var filterStyleEnum = FilteredListBonusRoundView.FilterType.beginsWith

I tried

@State private var filterStyleEnum = FilteredListBonusRoundView.self.FilterType.beginsWith

and

@State private var filterStyleEnum = FilteredListBonusRoundView.FilterType.self.beginsWith

and

@State private var filterStyleEnum = FilteredListBonusRoundView.FilterType.beginsWith.self

and

@State private var filterStyleEnum:FilteredListBonusRoundView.FilterType = .beginsWith

All give the same error.

@State private var filterStyleEnum = FilteredListBonusRoundView<NSManagedObject, View>.FilterType.beginsWith

gives a different error, I didn't think it was going to work but I tried.

My call to the subview works great later in the code

FilteredListBonusRoundView(filterKey: "lastname", filterValue: lastNameFilter, filterType: .beginsWith, sortInstructions: [NSSortDescriptor(keyPath: \Singer.lastname, ascending: true), NSSortDescriptor(keyPath: \Singer.firstname, ascending: true)])

but I can't figure out how to make the enum call update without moving the enum out of the filter list view's struct. I would like to leave the enum inside the subview if possible. I feel like this should work per the swift documentation on nested types

More code here: https://gist.github.com/carlynorama/a0d45aeb8f63c424671a4a5ed29e0fea

Anyone have any thoughts?

This course is so thoughtfully done, btw! Looking forward HWS+ when I'm done.

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.