I am requesting Core Data to return me its Entity entries in ascending order based on contentid:
let managedObjectContext = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext!
let sort = NSSortDescriptor(key:"contentid", ascending:true)
fetchRequest.sortDescriptors = [sort]
let fetchedResults = managedObjectContent.executeFetchRequest(fetchRequest, error: &error) as! [NSManagedObject]
How do I delete the first object in Core Data's returned, ascending entries?
I have also tried getting a single object by specifying:
fetchRequest.fetchLimit = 1
Thinking that this would return an [NSManagedObject], I attempted to then perform:
managedObjectContext.deleteObject(fetchedResults)
But it threw the error: cannot invoke method deleteObject with type '([NSManagedObject])'
. What exactly am I doing incorrectly? Do I need to convert [NSManagedObject]
to NSManagedObject
, perhaps?