如何解决受管对象崩溃EXC_BAD_ACCESS
|| 我有一个具有几个NSStrings的托管对象:@interface Establishment : NSManagedObject
{
}
@property (nonatomic,retain) NSString * name;
@property (nonatomic,retain) NSString * subtitle;
@property (nonatomic,retain) NSString * description;
我正在创建托管对象的实例,并将字符串分配给标签,例如:
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;
}
在这种情况下,名称具有值,但字幕和描述为零。当涉及字幕时,它将成功地使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--[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]
()
62856 0x00324d50 in-[UITableView _userSelectRowAtPendingSelectionIndexPath:]
()
62857 0x000377f6 in __NSFireDelayedPerform()
62858 0x00f67fe3,位于CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION
()
__CFRunLoopDoTimer中的62859 0x00f69594()
__CFRunLoopRun中的62860 0x00ec5cc9()
CFRunLoopRunSpecific中的62861 0x00ec5240()
CFRunLoopRunInMode中的62862 0x00ec5161()
GSEventRunModal中的62863 0x018bb268()
GSEventRun中的62864 0x018bb32d()
UIApplicationMain()中的62865 0x002c742e
62866 0x00002958在main(argc = 1,argv = 0xbfffefe4)在
/Users/Com_23/Documents/projects/Est_list/main.m:14
DataTable是我的UITableViewController。有人知道发生了什么吗?对我来说一切都很好。
解决方法
您不能给属性命名为“描述”。看到:
访问NSManagedObject中的属性会导致内存峰值和崩溃
参考(Apple文档):
http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Reference/CoreDataFramework/Classes/NSPropertyDescription_Class/NSPropertyDescription.html
属性描述单个值
在核心管理的对象中
数据框架。有不同
属性类型,每种由
封装了
特定属性行为-请参阅
NSAttributeDescription,
NSRelationshipDescription,以及
NSFetchedPropertyDescription。
请注意,属性名称不能为
与任何无参数方法相同
NSObject或NSManagedObject的名称。
例如,您不能给
属性名称为“描述”。那里
NSObject上有数百种方法
可能与财产冲突
名称-此列表可以在没有
来自框架或其他警告
库。你应该避免
一般字词(例如\“ font”,和
“颜色”)以及单词或词组
与可可范式(例如
“ isEditing”和“ objectSpecifier”)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。