Below is my code:
First Category.h
#import <Foundation/Foundation.h>
@interface Category : NSObject {
NSMutableArray *items;
NSString *name;
NSString *description;
NSString *imagePath;
NSString *id;
}
@property (nonatomic, retain) NSMutableArray *items;
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *description;
@property (nonatomic, retain) NSString *id;
@property (nonatomic, retain) NSString *imagePath;
-(id)init;
-(UIImage*)getImage;
@end
And the controller:
- (id)initWithCategory:(Category *)categoryItem
{
self = [super init];
if (self) {
self.category = categoryItem;
}
return self;
}
And in the header file:
@property (nonatomic, retain) Category *category;
- (id)initWithCategory:(Category *)categoryItem;
I want that self.category and categoryItem would be exactly the same.
Update: I am so sorry, error was not from here. Thank you for your help.
If
categoryis a property, then you should useself.category.However, assuming that you have synthesized your property with a backing ivar such as
_category(@synthesize category = _category), then you should refer to the ivar and use_categoryin the init method.