I am adding to a simple entity, a list of names (from an array). But before saving the entity, I would like them to be sorted. Please could someone be so kind as to tell me how to do this?
I've seen how to sort some fetched data, but I do not know how to do this. A written example would be greatly appreciated. Many thanks.
NSManagedObjectContext *context = [self managedObjectContext];
NSString *myTempString;
for (databaseMakerVC *aName in peoplesNames.theArray) {
myTempString = [[NSString alloc] initWithFormat:@"%@", aName];
peoplesNamesObject *newObject = [NSEntityDescription
insertNewObjectForEntityForName:@"peoplesNamesObject"
inManagedObjectContext:context];
newObject.aName = myTempString;
}
// *** Do the sorting here!? ***
// Save the context
NSError *error = nil;
if (![context save:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
}