Reputation: 4732
I have a NSFetchRequest to search of core data entities. It finds them fine, but I want to set the cell's text to the entity's name
attribute.
I currently have this but I am setting the object itself to the title, instead of the name attribute, how can I fix this?
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Routine" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
NSError *error = nil;
NSArray *results = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
self.routineArray = results;
[fetchRequest release];
cell.textLabel.text = [self.routineArray objectAtIndex:indexPath.row];
Upvotes: 1
Views: 247
Reputation:
Try :
cell.textLabel.text = [[self.routineArray objectAtIndex:indexPath.row] name];
EDIT
If your Routine
instances are in routineArray
(given that name, I suppose) :
// get the Routine instance
Routine *r = [self.routineArray objectAtIndex:indexPath.row];
// now you got your instance, set anything you want on r...
// ...
// and then set its name as the text for textLabel using previous instruction
Upvotes: 3