Re: IPhone- Datasensitive bug from CoreData...
Re: IPhone- Datasensitive bug from CoreData...
- Subject: Re: IPhone- Datasensitive bug from CoreData...
- From: Brian Bruinewoud <email@hidden>
- Date: Fri, 25 Dec 2009 17:15:56 +1100
Final set of information for today.
Sometimes the console just had INVALID INSTRUCTION without any error message.
Mostly its the below error message but with different target objects. The latest was UIImageView - as far as I know, I have no UIImageVIew in my app (unless it's part of the implementation of another control/view, which makes sense).
Finally, another scenario that works:
With a fresh app (deleted from the simulator and re-installed), create a person and add a bad deed to that person. Quit and restart the app then attempt to add a good deed. Success.
It seems that the bug is triggered when:
1. Adding to the same user
2. In the same session (ie, without quiting the app in between)
3. A new deed that has a score where sign(new-score) != sign(previous-score)
:-(
Until tomorrow...
On 25/12/2009, at 16:48 , Brian Bruinewoud wrote:
> Oh, sorry, here is the message in the Console:
>
> *** -[NSCFType controllerDidChangeContent:]: unrecognized selector sent to instance 0x3a11d70
> Serious application error. Exception was caught during Core Data change processing: *** -[NSCFType controllerDidChangeContent:]: unrecognized selector sent to instance 0x3a11d70 with userInfo (null)
> *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFType controllerDidChangeContent:]: unrecognized selector sent to instance 0x3a11d70'
> Stack: ( ...
>
> On 25/12/2009, at 16:40 , Brian Bruinewoud wrote:
>
>> This has me totally stumped.
>>
>> I have an app that contains (currently) three Entities:
>> Person
>> Deed; and
>> DeedDoneByPerson
>>
>> Deed is effectively a template object. I'll probably re-do the object model but I want to understand what's going on with this bug first.
>>
>> Deeds can be good or not and have a degree of goodness.
>>
>> Here is the code that creates a new deed and deedDoneByPerson:
>>
>> NSManagedObject *newDeed = [ NSEntityDescription insertNewObjectForEntityForName: @"Deed"
>> inManagedObjectContext: context ];
>>
>> int score;
>> if( self.isGood ) score = sender.tag;
>> else score = - sender.tag;
>>
>> [newDeed setValue: self.deedName.text forKey: @"deedName" ];
>> [newDeed setValue: [ NSNumber numberWithBool: self.isGood ] forKey: @"isGood" ];
>> [newDeed setValue: [ NSNumber numberWithInt: score ] forKey: @"points" ];
>>
>> NSManagedObject *newDeedDoneByPerson = [ NSEntityDescription insertNewObjectForEntityForName: @"DeedDoneByPerson"
>> inManagedObjectContext: context ];
>>
>> [newDeedDoneByPerson setValue: newDeed forKey: @"deedDone" ];
>> [newDeedDoneByPerson setValue: selectedPerson forKey: @"byPerson" ];
>> [newDeedDoneByPerson setValue: [ NSNumber numberWithBool: self.isGood ] forKey: @"isGood" ];
>> // let 'points' and 'instances' default
>>
>> FYI2( @":: Create new deed [%@]", self.deedName.text );
>> NSError *error;
>> if (![context save:&error]) //!!!!!!! CRASHES HERE !!!!!!!!
>> {
>> NSLog(@"!! Unresolved error %@, %@", error, [error userInfo]);
>> abort();
>> }
>>
>>
>> The following scenarios work:
>> With a fresh app (deleted from the simulator and re-installed), create a person and add any number of bad deeds to that person - they are displayed correctly and sqlite has the expected contents.
>> With a fresh app (deleted from the simulator and re-installed), create a person and add any number of good deeds to that person - they are displayed correctly and sqlite has the expected contents.
>> With a fresh app (deleted from the simulator and re-installed), create a person and add any number of bad deeds to that person - they are displayed correctly and sqlite has the expected contents. Then create another person and add any number of good deeds to that person - they are displayed correctly and sqlite has the expected contents
>>
>> The following scenario does NOT work:
>> With a fresh app (deleted from the simulator and re-installed), create a person and add a bad deed to that person then attempt to add a good deed. BOOM
>>
>> Stack trace:
>> #0 0x93affedb in objc_msgSend
>> #1 0x939f4b6c in ??
>> #2 0x0001763a in _nsnote_callback
>> #3 0x01d34005 in _CFXNotificationPostNotification
>> #4 0x00014ef0 in -[NSNotificationCenter postNotificationName:object:userInfo:]
>> #5 0x01ba717d in -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:]
>> #6 0x01c06763 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:]
>> #7 0x01b8b5ea in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:]
>> #8 0x01bc1728 in -[NSManagedObjectContext save:]
>> #9 0x00005434 in -[NewDeedViewController commit:] at NewDeedViewController.m:131 <------------------- CODE ABOVE
>> #10 0x00298459 in -[UIApplication sendAction:to:from:forEvent:]
>> #11 0x002fbba2 in -[UIControl sendAction:to:forEvent:]
>> #12 0x002fddc3 in -[UIControl(Internal) _sendActionsForEvents:withEvent:]
>> #13 0x002fcb0f in -[UIControl touchesEnded:withEvent:]
>> #14 0x002b1e33 in -[UIWindow _sendTouchesForEvent:]
>> #15 0x0029b81c in -[UIApplication sendEvent:]
>> #16 0x002a20b5 in _UIApplicationHandleEvent
>> #17 0x0252cef1 in PurpleEventCallback
>> #18 0x01d40b80 in CFRunLoopRunSpecific
>> #19 0x01d3fc48 in CFRunLoopRunInMode
>> #20 0x0252b7ad in GSEventRunModal
>> #21 0x0252b872 in GSEventRun
>> #22 0x002a3003 in UIApplicationMain
>> #23 0x00001cb4 in main at main.m:14
>>
>> I don't understand how the value of 'score' breaks things. If I get rid of the negation in this code:
>> int score;
>> if( self.isGood ) score = sender.tag;
>> else score = - sender.tag;
>> everything works fine: adding good and bad to the same person is acceptable.
>>
>> Any suggestions on what to investigate?
>>
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden