Hi,
I experience a very weird behavior and I am at wit's end.
I am subclassing NSManagedObject that I generated by xcode. Since I might change the schema I used the recommended approach of not adding code to the subclass, but through a category (I am calculating new attributes based on other attributes that are in the database).
Here is my code:
.h file of Category file:
.m file of Category file:
Now, I am trying to access the new attributes like this:
Now, it seems everything works great! xCode recognizes the new attributes, so it autocompletes - when I start type "dia..." I can choose from the popup diamondUIImage.
But when I run the app, I keep get a sigabrt error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DiamondDetails diamondUIImage]: unrecognized selector sent to instance 0x7f56db0'
Can't figure out why, been searching for 3 hours already. Probably I missing something obvious, but any help will be greately appreciated
I experience a very weird behavior and I am at wit's end.
I am subclassing NSManagedObject that I generated by xcode. Since I might change the schema I used the recommended approach of not adding code to the subclass, but through a category (I am calculating new attributes based on other attributes that are in the database).
Here is my code:
.h file of Category file:
Code:
#import "DiamondDetails.h"
@interface DiamondDetails (DiamondImageCategory)
-(UIImage *) diamondUIImage;
-(UIImage *) certificateUIImage;
@end
.m file of Category file:
Code:
@implementation DiamondDetails (DiamondImageCategory)
-(UIImage *) diamondUIImage {
NSLog(@"Diamond image called on diamond details");
if (self.diamondImage != nil)return [UIImage imageNamed:self.diamondImage];
else {
NSLog(@"No image. Returning nil...");
return nil;
}
}
-(UIImage*) certificateUIImage {
if (self.certificateImage != nil)return [UIImage imageNamed:self.certificateImage];
else {
NSLog(@"No cert image. Returning nil...");
return nil;
}
}
Now, I am trying to access the new attributes like this:
Code:
UIImage * img = [d.diamondDetails diamondUIImage];
Now, it seems everything works great! xCode recognizes the new attributes, so it autocompletes - when I start type "dia..." I can choose from the popup diamondUIImage.
But when I run the app, I keep get a sigabrt error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DiamondDetails diamondUIImage]: unrecognized selector sent to instance 0x7f56db0'
Can't figure out why, been searching for 3 hours already. Probably I missing something obvious, but any help will be greately appreciated