I have a managed object that has several NSStrings:
@interface Establishment : NSManagedObject
{
}
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSString * subtitle;
@property (nonatomic, retain) NSString * description;
I am creating an instance of the managed object and assigning the strings to labels, as such:
if ([establishmentData.name length]!= 0) {
estabName.text = establishmentData.name;
} else {
estabName.hidden = YES;
}
if ([establishmentData.subtitle length]!= 0) {
estabTitle.text = establishmentData.subtitle;
} else {
estabTitle.hidden = YES;
}
if ([establishmentData.description length]!= 0) {
estabDescription.text = establishmentData.description;
} else {
estabDescription.hidden = YES;
}
In this case, name has a value, but subtitle and description are nil. When it gets to subtitle, it successfully fails the if and hides the text field, but when it gets to description it crashes EXC_BAD_ACCESS. I tried simply NSLogging establishmentData.description and it still crashes
Backtrace throws out 62,000 lines of this:
62851 0x00d3dbbf in _PF_Handler_Public_GetProperty ()
62852 0x00d3f2fb in -[NSManagedObject _descriptionValues] ()
62853 0x00d3d6b5 in -[NSManagedObject description] ()
and ends with
62854 0x00004b90 in -[DataTable tableView:didSelectRowAtIndexPath:]
(self=0x4d48df0, _cmd=0x6d59e3,
tableView=0x505d200,
indexPath=0x6111b00) at
/Users/Com_23/Documents/projects/Est_list/Classes/DataTable.m:33062855 0x0032e794 in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]
()
62856 0x00324d50 in -[UITableView _userSelectRowAtPendingSelectionIndexPath:]
()
62857 0x000377f6 in __NSFireDelayedPerform ()
62858 0x00f67fe3 in CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION
()
62859 0x00f69594 in __CFRunLoopDoTimer ()
62860 0x00ec5cc9 in __CFRunLoopRun ()
62861 0x00ec5240 in CFRunLoopRunSpecific ()
62862 0x00ec5161 in CFRunLoopRunInMode ()
62863 0x018bb268 in GSEventRunModal ()
62864 0x018bb32d in GSEventRun ()
62865 0x002c742e in UIApplicationMain ()
62866 0x00002958 in main (argc=1, argv=0xbfffefe4) at
/Users/Com_23/Documents/projects/Est_list/main.m:14
DataTable being my UITableViewController. Does anyone have any idea what is going on? Everything looks fine to me.
You cannot give a property the name “description”. See:
Accessing a property in NSManagedObject causes memory spike and crash
Reference (Apple Documentation):
http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Reference/CoreDataFramework/Classes/NSPropertyDescription_Class/NSPropertyDescription.html