Core-Data: print object contents

How to print the contents of an object, for example. customer?

I want the data to be tables, for example, entity data should print like this:

Name | Surname | Phone number | Email | Dob

I also need to apply a search predicate before printing data, for example. printed members born after 1984

Can someone tell me how should I do this?

Thank!

+1
source share
1 answer

I found this link that helped me use the basic data: http://iphoneinaction.manning.com/iphone_in_action/2009/09/core-data-part-3-retrieving-data.html

Passing an entity to an array, combining an array and NSLog data for each result. For instance:.

NSEntityDescription *entity = [NSEntityDescription entityForName:@"news" 
                                          inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"url=%@",theUrl];
[fetchRequest setPredicate:predicate];

NSError *error;
NSArray *items = [self.managedObjectContext
                   executeFetchRequest:fetchRequest error:&error];

for (news *theNews in items) {
    NSLog(@"Title: %@, Date: %@, News: %@", [theNews title], [theNews date], [theNews news]);
}

[fetchRequest release];
+4

All Articles