0
下面是我的代碼:如何將對象分配給IOS中的本地對象?
首先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
而且控制器:
- (id)initWithCategory:(Category *)categoryItem
{
self = [super init];
if (self) {
self.category = categoryItem;
}
return self;
}
而且在頭文件:
@property (nonatomic, retain) Category *category;
- (id)initWithCategory:(Category *)categoryItem;
我想自我.category和categoryItem將完全相同。
更新:我很抱歉,錯誤不是從這裏。感謝您的幫助。
'無法賦值'是什麼意思?任何形式的警告或標誌? – CodaFi 2012-03-26 21:30:29
值不一樣。我希望該類別對象將是categoryItem。 – Burak 2012-03-26 21:36:38
我不相信'category'在'initWithCategory'中的賦值後不等於'categoryItem'。你怎麼看? – mattjgalloway 2012-03-26 22:05:15