ios - Delete NSManagedObject and later refresh tableView doesn't work correctly -
i have 2 nsmanagedobject (person , car) , relationship "not inverse" between them. relationship not inverse.
i have 2 viewcontrollers, first 1 has tableview shows each instance of person object , second has table view shows every car of person. first view controller shows name of person , number of cars of person.
all works fine issue appear when try delete car of person. think remove object correctly:
[_person removecarssobject:car1];
but issue appear when being in second view, remove car, , go first view: number of cars doesn't refresh , app crashes.
when add car , go second view works , 'number of cars' increases.
when run app again, car deleted. why think way delete object correct.
i've realized app works number of cars going take value 0, otherwise app crashes.
i hope can me, thank you!
update:
i’ve changed code, , reload data of table view in
- (void)viewwillappear:(bool)animated{
this way can see proper data in table view, but, 1 second approx, later app crashes log: “thread 1: exc_bad_access(code=exc_i386_gpflt)"
all relationships in "model data" have delete rule property : nullify. maybe causing crash.
finally have issue solved. enabling zombie objects got more information crash. app crashing following message:
[viewcontroller tableview:caneditrowatindexpath:]: message sent deallocated instance 0xaae64d0
i had method this:
- (bool)tableview:(uitableview *)tableview caneditrowatindexpath:(nsindexpath *)indexpath { return yes; }
searching, found question in stackoverflow says same: tableview:caneditrowatindexpath: crash when popping viewcontroller
the issue solved adding following code:
- (void)viewwilldisappear:(bool)animated { [super viewwilldisappear:animated]; [table setediting:no]; }
Comments
Post a Comment