Bea*_*ker 0 iphone cocoa-touch core-data
我有一个托管对象,有几个NSStrings:
@interface Establishment : NSManagedObject
{
}
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSString * subtitle;
@property (nonatomic, retain) NSString * description;
Run Code Online (Sandbox Code Playgroud)
我正在创建托管对象的实例并将字符串分配给标签,如下所示:
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;
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,name有一个值,但是subtitle和description是nil.当它到达副标题时,它成功地失败了if并隐藏了文本字段,但是当它到达描述时它崩溃了EXC_BAD_ACCESS.我尝试了简单的NSLogging establishmentData.description,它仍然崩溃
Backtrace抛出了62,000行:
_PF_Handler_Public_GetProperty()中的62851 0x00d3dbbf
62852 0x00d3f2fb in - [NSManagedObject _descriptionValues]()
62853 0x00d3d6b5 in - [NSManagedObject description]()
最后以
62854 0x00004b90 in - [DataTable tableView:didSelectRowAtIndexPath:]
(self = 0x4d48df0,_cmd = 0x6d59e3,tableView = 0x505d200,indexPath = 0x6111b00)/Users/Com_23/Documents/projects/Est_list/Classes/DataTable.m:330
62855 0x0032e794 in - [UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]
()
62856 0x00324d50 in - [UITableView _userSelectRowAtPendingSelectionIndexPath:]
()
__NSFireDelayedPerform()中的62857 0x000377f6
CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION中的62858 0x00f67fe3
()
__CFRunLoopDoTimer()中的62859 0x00f69594
__CFRunLoopRun()中的62860 0x00ec5cc9
CFRunLoopRunSpecific()中的62861 0x00ec5240
CFRunLoopRunInMode()中的62862 0x00ec5161
GSEventRunModal()中的62863 0x018bb268
GSEventRun()中的62864 0x018bb32d
UIApplicationMain中的62865 0x002c742e()
62866 0x00002958 in main(argc = 1,argv = 0xbfffefe4)at
/Users/Com_23/Documents/projects/Est_list/main.m:14
DataTable是我的UITableViewController.有谁知道发生了什么事?一切看起来都很好.
您不能将属性命名为"description".看到:
访问NSManagedObject中的属性会导致内存峰值和崩溃
参考(Apple文档):
属性描述Core Data Framework管理的对象中的单个值.有不同类型的属性,每个属性由一个子类表示,该子类封装了特定的属性行为 - 请参阅NSAttributeDescription,NSRelationshipDescription和NSFetchedPropertyDescription.
请注意,属性名称不能与NSObject或NSManagedObject的任何无参数方法名称相同. 例如,您不能为属性指定名称"description".NSObject上有数百个可能与属性名称冲突的方法 - 这个列表可以在没有框架或其他库的警告的情况下增长.您应该避免使用非常一般的单词(如"font"和"color")以及与Cocoa范例重叠的单词或短语(例如"isEditing"和"objectSpecifier")
| 归档时间: |
|
| 查看次数: |
1545 次 |
| 最近记录: |