Sagar Babu
Sagar Babu

Reputation: 53

how to display Core Data fetched data in user readable form

I am fetching data to array from Core Data using following line of code.

array = [DCCoreDataHelper executeFetchRequestForEntity:@"entity1" usingPredicate:nil sortDescriptors:nil context:[DCCoreDataHelper currentMOC]];

I printed this array it is showing like:

"<Aeri: 0x9184ff0> (entity: entity1; id: 0x9182750 <x-coredata://C37AD050-9FB1-4CF3-9E8D-1E1FC31E8341/ACUPClaim/p1> ; data: <fault>

how can convert this to user readable form?

Upvotes: 0

Views: 36

Answers (1)

cdescours
cdescours

Reputation: 6022

Have you tried to implement the -(NSString*) description method on your entity ?

In generated CoreData classes, it might be useful to use an objective-C category to define such specific user-methods, to prevent loosing your modifications if you regenerate your entity definition.

Edited :

in your implementation of your entity, considering your entity has 2 String properties code and name, you can add this method :

-(NSString*) description
{
   return [[self.code stringByAppendingString:@" - "]  stringByAppendingString:self.name];
}

Upvotes: 2

Related Questions