gpt4 book ai didi

ios - 打开 uiviewcontroller 后出现 NSObjectInaccessibleException

转载 作者:行者123 更新时间:2023-11-29 05:01:29 25 4
gpt4 key购买 nike

我正在开发一个应用程序,其中有一个自定义选项卡栏打开不同的表格 View 。 TableView 的信息由 JSON 远程源提供。并使用自定义 nsmanagementobject 保存到 Core Data 中。

我在didSelectRowAtIndexPath中打开和关闭uiview后触发该错误。详细 View 在表格 View 上方打开,并在角落有一个关闭按钮。该 View 仅供阅读文章,不可编辑、重写或删除。我打开和关闭详细 View 两次后出现该错误。

日志显示 NSManagedObject 已失效。但是,当我不删除或更新对象时,如何实现。每个单元格行都会发生这种情况。

我做错了什么?

日志:

* Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'The NSManagedObject with ID:0x75401c0 has been invalidated.'
*
Call stack at first throw:
(
0 CoreFoundation 0x013d15a9 exceptionPreprocess + 185
1 libobjc.A.dylib 0x01525313 objc_exception_throw + 44
2 CoreData 0x0117f120 -[NSFaultHandler _fireFirstAndSecondLevelFaultsForObject:withContext:] + 0
3 CoreData 0x01110933 _PF_FulfillDeferredFault + 499
4 CoreData 0x011149af _sharedIMPL_pvfk_core + 95
5 CoreData 0x011247c0 _pvfk_9 + 32
6 Ultima 0x00014bf7 -[ProgramTable tableView:cellForRowAtIndexPath:] + 4247
7 UIKit 0x004c1b98 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
8 UIKit 0x004b74cc -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
9 UIKit 0x004cc8cc -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
10 UIKit 0x004c490c -[UITableView layoutSubviews] + 242
11 QuartzCore 0x0014fa5a -[CALayer layoutSublayers] + 181
12 QuartzCore 0x00151ddc CALayerLayoutIfNeeded + 220
13 QuartzCore 0x000f70b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
14 QuartzCore 0x000f8294 _ZN2CA11Transaction6commitEv + 292
15 QuartzCore 0x000f846d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
16 CoreFoundation 0x013b289b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION
+ 27
17 CoreFoundation 0x013476e7 __CFRunLoopDoObservers + 295
18 CoreFoundation 0x013101d7 __CFRunLoopRun + 1575
19 CoreFoundation 0x0130f840 CFRunLoopRunSpecific + 208
20 CoreFoundation 0x0130f761 CFRunLoopRunInMode + 97
21 GraphicsServices 0x01e6d1c4 GSEventRunModal + 217
22 GraphicsServices 0x01e6d289 GSEventRun + 115
23 UIKit 0x0045ac93 UIApplicationMain + 1160
24 Ultima 0x000028e9 main + 121
25 Ultima 0x00002865 start + 53 )
terminate called throwing an exception[Switching to process 429 thread 0xec03]
sharedlibrary apply-load-rules all
Current language: auto; currently objective-c

我的 cellForRowAtIndexPath 看起来像:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";

ProgramCelle *cell = (ProgramCelle*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[ProgramCelle alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
int row = indexPath.row;
int section = indexPath.section;

NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"HH:mm"];

if(section == 0){
Program *p =[eight objectAtIndex:row];
cell.primaryTitle.text = p.title;
cell.primaryTitle.textColor = [UIColor blueColor];
Scene *s = p.scene;
cell.secondaryTitle.text = s.name;
NSDate *dato = p.tidspunkt;

NSString *time = [formatter stringFromDate:dato];
cell.klokke.text = time;

}
if(section == 1){
Program *p =[nine objectAtIndex:row];
cell.primaryTitle.text = p.title;
cell.primaryTitle.textColor = [UIColor blueColor];
Scene *s = p.scene;
cell.secondaryTitle.text = s.name;
NSDate *dato = p.tidspunkt;

NSString *time = [formatter stringFromDate:dato];
cell.klokke.text = time;
}
if(section == 2){
Program *p =[ten objectAtIndex:row];
cell.primaryTitle.text = p.title;
cell.primaryTitle.textColor = [UIColor blueColor];
Scene *s = p.scene;
cell.secondaryTitle.text = s.name;
NSDate *dato = p.tidspunkt;

NSString *time = [formatter stringFromDate:dato];
cell.klokke.text = time;
}
if(section == 3){
Program *p =[eleven objectAtIndex:row];
cell.primaryTitle.text = p.title;
cell.primaryTitle.textColor = [UIColor blueColor];
Scene *s = p.scene;
cell.secondaryTitle.text = s.name;
NSDate *dato = p.tidspunkt;

NSString *time = [formatter stringFromDate:dato];
cell.klokke.text = time;
}
if(section == 4){
Program *p =[twelve objectAtIndex:row];
cell.primaryTitle.text = p.title;
cell.primaryTitle.textColor = [UIColor blueColor];
Scene *s = p.scene;
cell.secondaryTitle.text = s.name;
NSDate *dato = p.tidspunkt;

NSString *time = [formatter stringFromDate:dato];
cell.klokke.text = time;
}
if(section == 5){
Program *p =[thirteen objectAtIndex:row];
cell.primaryTitle.text = p.title;
cell.primaryTitle.textColor = [UIColor blueColor];
Scene *s = p.scene;
cell.secondaryTitle.text = s.name;
NSDate *dato = p.tidspunkt;

NSString *time = [formatter stringFromDate:dato];
cell.klokke.text = time;
}
if(section == 6){
Program *p =[fourteen objectAtIndex:row];
cell.primaryTitle.text = p.title;
cell.primaryTitle.textColor = [UIColor blueColor];
Scene *s = p.scene;
cell.secondaryTitle.text = s.name;
NSDate *dato = p.tidspunkt;

NSString *time = [formatter stringFromDate:dato];
cell.klokke.text = time;
}
if(section == 7){
Program *p =[fifthteen objectAtIndex:row];
cell.primaryTitle.text = p.title;
cell.primaryTitle.textColor = [UIColor blueColor];
Scene *s = p.scene;
cell.secondaryTitle.text = s.name;
NSDate *dato = p.tidspunkt;

NSString *time = [formatter stringFromDate:dato];
cell.klokke.text = time;
}
if(section == 8){

Program *p =[sixteen objectAtIndex:row];
cell.primaryTitle.text = p.title;
cell.primaryTitle.textColor = [UIColor blueColor];
Scene *s = p.scene;
cell.secondaryTitle.text = s.name;
NSDate *dato = p.tidspunkt;

NSString *time = [formatter stringFromDate:dato];
cell.klokke.text = time;
}
if(section == 9){
Program *p =[seventeen objectAtIndex:row];
cell.primaryTitle.text = p.title;
cell.primaryTitle.textColor = [UIColor blueColor];
Scene *s = p.scene;
cell.secondaryTitle.text = s.name;
NSDate *dato = p.tidspunkt;

NSString *time = [formatter stringFromDate:dato];
cell.klokke.text = time;
}
[formatter release];
return cell;
}

其中八、九、十...是在 viewdidLoad 中启动并在 dealloc 中释放的 NSArray。

最佳答案

您可能没有将对象保留足够长的时间(也称为自动释放)。因此,当一段时间过去后,您会尝试访问不再存在的东西。尝试将数据传递到 NSMutableArray 并将其用作“tableView:cellForRowAtIndexPath”上的数据源。

关于ios - 打开 uiviewcontroller 后出现 NSObjectInaccessibleException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6814757/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com