PDA

View Full Version : Core Data properties in code




theunixgeek
Jun 12, 2009, 10:36 AM
How can I access a Core Data entity's properties in code? I have an entity with title (string) and description (binary) properties. Is there a way to retrieve these two arrays programmatically so I can use them in a for-loop?



HiRez
Jun 12, 2009, 12:08 PM
How can I access a Core Data entity's properties in code? I have an entity with title (string) and description (binary) properties. Is there a way to retrieve these two arrays programmatically so I can use them in a for-loop?

NSArray *nameArray = myCoreDataObject.name;
NSArray *descriptionArray = myCoreDataObject.description;

"name" and "description" don't sound like arrays to me though, if those are arrays as you say, they are poorly named. If they are simple properties instead, it would be something like:

NSString *aName = myCoreDataObject.name;
NSData *description = myCoreDataObject.description;