I am developing a app where with a custom tabbar opening different tableview. The information to the tableview is feeded by a JSON remote feed. And saved into Core Data with custom nsmanagedobject.
The error is triggered after I opening and closing uiview in didSelectRowAtIndexPath. The detail view is opening over the tableview and have a closing button in the corner. The view is only for read articles, not for edit, rewrite or delete. The error appear after I have opened and closed the detail view twice.
The log say that the NSManagedObject is has been invalidated. But how, when i am not deleting or updating the object. It happening with every cell row.
What i am doing wrong?
The log:
* 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
My cellForRowAtIndexPath looks like:
- (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;
}
Where eight, nine, ten … are NSArrays that is initiated in viewdidLoad and released in dealloc.
I found it out by my self. When I am closing the overlaying viewcontroller, I have to reload the data of the tableview. It was not a problem of any array or deleting any object.
Like