I have this code for Coredata saving, and I'm trying to implement groups enumeration from another example but I fail with multiple errors every tine I try.
"Value of type 'String?' has no member 'rawValue'; did you mean 'hashValue'?"
"Value of type 'Any' has no member 'group'
Im very confused after so many tries, I will post the code from where I started.
struct ChannelController {
static func create(Group: String, Title: String, Url: URL, Logo: URL, Playlist: Playlist) {
let _ = Channel(Group: Group, Title: Title, Url: Url, Logo: Logo, Playlist: Playlist)
}
}
extension Channel {
@discardableResult convenience init(Group: String, Title: String, Url: URL, Logo: URL, Playlist: Playlist, context: NSManagedObjectContext = CoreDataStack.context) {
self.init(context: context)
// MARK: Properties
self.group = Group
self.title = Title
self.url = Url
self.logo = Logo
self.playlist = Playlist
}
}
Here is the example I want to implement.
struct DataItem: Equatable {
// MARK: Types
enum Group: String {
case Scenery
case Iceland
case Lola
case Baby
static let allGroups: [Group] = [.Scenery, .Iceland, .Lola, .Baby]
}
// MARK: Properties
let group: Group
let number: Int
let title: String
var identifier: String {
return "\(group.rawValue).\(number)"
}
}
What I want to archive is to be able to map and filter objects stored in Group categories.
Some help will be very apreciated.