Hello, again!
I posted here a couple of days ago, regarding core data and how to properly store it. I did in fact fix this, but I have now faced another small problem of mine. You see, I have a entity called "Profiles". Here I have the following attributes "name", "age", "country". However, what I want to do - is to only display one instance of the names. Let's say I have three profiles named "Bob", and two profiles named "John". Instead of displaying three "Bob" and two "John", how can I avoid this and only display unique names once?
Here is what I have so far, it's not that much - as I don't have any clue on how to do this. I searched on Google, but I didn't find anything.
let delegate = UIApplication.sharedApplication().delegate as! AppDelegate
let context = delegate.managedObjectContext
let request = NSFetchRequest(entityName: "Profiles")
let predicate = NSPredicate(format: "name == '\(selectedName)'")
request.predicate = predicate
var err:NSError?
do {
ProfileName = try context.executeFetchRequest(request) as! [NSManagedObject]
ProfileAge = try context.executeFetchRequest(request) as! [NSManagedObject]
ProfileCountry = try context.executeFetchRequest(request) as! [NSManagedObject]
} catch let err1 as NSError {
err = err1
}
if err != nil {
print("Problem loading data..")
}
As you may understand, this is only a snippet of my code. Help would be very appreciated.