Ios 如何保留自动删除的核心数据字符串
我有一个模态对象,它有几个字符串,其中一个字符串总是被释放。使用malloc断点和僵尸检测工具,我找到了对象。但现在我不知道该怎么办,因为我正在使用ARC 我在下面放了一些代码 核心数据管理对象Ios 如何保留自动删除的核心数据字符串,ios,instruments,dealloc,Ios,Instruments,Dealloc,我有一个模态对象,它有几个字符串,其中一个字符串总是被释放。使用malloc断点和僵尸检测工具,我找到了对象。但现在我不知道该怎么办,因为我正在使用ARC 我在下面放了一些代码 核心数据管理对象 @property (nonatomic, retain) NSString * newExVal; 在两个地方访问它 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexP
@property (nonatomic, retain) NSString * newExVal;
在两个地方访问它
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
ABC *abc = [abcList objectAtIndex:indexPath.row];
int newCnt = [abc.newExVal intValue];
}
同样地
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ABC *abc = [abcList objectAtIndex:indexPath.row];
int newCnt = [abc.newExVal intValue];
}
它在单元格FORROWATINDEXPATH
中崩溃,而不是在高度FORROWATINDEXPATH
中崩溃。我知道heightforrowatinexpath
在cellforrowatinexpath
之前被调用。我应该做些什么来确保这个字符串没有被释放
编辑:错误消息-[CFString intValue]:发送到解除分配实例0x98707e0的消息
我在xml解析器中这样赋值
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if (ord_newExp) {
ord_newExp = NO;
orderList.newExceptionVal = string;
}
}
你收到错误信息了吗?如果是,请张贴。你想用abcList.newExVal做什么?我想abcList是一个数组,所以不能像那样使用点符号。还有,newExVal和newExceptionVal是一样的吗?我的错。。没有输入正确的代码。现在我已经改正了。。我已将错误消息放入您的模型中,是否为newExVal的一部分?如果不是,则至少将其作为一个瞬态部分,并显示在何处以及如何为其赋值。是,它是模型的一部分。已编辑。如果您在ARC上,则newExVal的属性应为
非原子、强
。