I get an error "Invalid receiver type 'NSInteger'" on this line in my implementation of a simple class:
self.price = p; // this line throws error
Should I be specifying price as copy
? More details:
header file:
@interface SafeItem : NSObject {
NSString *name;
NSInteger price;
NSString *category;
NSInteger itemid;
BOOL hasImage;
}
@property (nonatomic,copy) NSString *name;
@property (nonatomic) NSInteger price;
@property (nonatomic,copy) NSString *category;
@property NSInteger itemid;
@property BOOL hasImage;
- (id)initWithName:(NSString*) n price:(NSInteger) p category:(NSString*) c;
@end
implementation:
@implementation SafeItem
@synthesize name, price, category, itemid, hasImage;
- (id)initWithName:(NSString*) n price:(NSInteger) p category:(NSString*) c {
if(self=[super init]){
self.itemid = [SafeItem getNextId];
self.name = [n copy];
self.price = p; // this line throws error
self.category = [c copy];
}
return self;
}