views:

94

answers:

1

I have the following core data model with two entities:

entity "item" which holds name, date, description and a to many relationship "image". image is optional.

entity "image" holds url, name and relationship to one item.

I load the executed Fetchrequest into this NSArray "entityArray"

This is what I do to display my data in a UITableView for example to display title in main cell:

NSManagedObject *object = (NSManagedObject *)[entityArray objectAtIndex:indexPath.row];

cell.textLabel.text=[object valueForKey:@"title"];  

Now I have no clue how to access my relationship image ([object valueForKey:@"image"]), because it contains more than just a string.

+1  A: 

First, -objectAtIndex: returns an id so no casting is required.

Second you can access the image the same way you accessed the title:

NSSet *images = [object valueForKey];

You can then iterate over that set and pick the image you want to work with.

Marcus S. Zarra
That did it, thank you :)
georgeliquor