Re: extending automatic core data entity classes
Re: extending automatic core data entity classes
- Subject: Re: extending automatic core data entity classes
- From: Alexander Spohr <email@hidden>
- Date: Mon, 28 Dec 2009 12:14:16 +0100
Am 28.12.2009 um 07:59 schrieb Damien Cooke:
> iPhone Simulator 3.1 (139.1), iPhone OS 3.1.2 (7D11)
> *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSManagedObject returnAdditiveWarningByType]: unrecognized selector sent to instance 0x3a2d580'
What class is at 0x3a2d580?
Show debug output.
> It is called like this in the code
> AdditiveEntity *additiveEntity = (AdditiveEntity *)[fetchedResultsController objectAtIndexPath:indexPath];
> if ([additiveEntity returnAdditiveWarningByType] == ADDITIVE_WARNING_TYPE_WARNING)
> {
> ....
> }
>
> This indicates that despite the fact I have cast the object to an additiveEntity the class I am trying to apply this to is of type NSManagedObject not my class at all.
Right! Why don’t you log what you get and have a look why it is not what you expect?
> So my questions are am I a complete idiot and have missed something simple?
How should we know? You don’t show how your fetchedResultsController gets its contents.
> Am I able to add convenience methods to the classes that core data generates for use as the entity classes if so can someone tell me what am I doing wrong?
Not without seeing code. Besides, I would not touch the generated classes. Use a category instead.
> Is there something stopping me from casting the result of [fetchedResultsController objectAtIndexPath:indexPath] to a AdditiveEntity which is a subclass of NSManagedObject anyway?
You can cast your objects even to a BOOL. But that will not make it a BOOL if it is not a BOOL already.
> @interface AdditiveEntity : NSManagedObject {
> }
>
> - (ADDITIVE_WARNING_TYPE)returnAdditiveWarningByType;
>
> @end
So this is your header. Does your class have an implementation of that method?
atze
_______________________________________________
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