目标C:如何在我的模型中使用UIImage作为属性?

时间:2015-08-22 16:25:11

标签: objective-c

我有var lights_array = []; $.when($.getJSON("resources/php/getjson.php",function(data){ })).then(function(json){ var verajson = json; var lights_obj = verajson.devices; for (i = 0; i < verajson.devices.length; i++) { var lights_ids = verajson.devices[i].id; lights_array.push(lights_ids); } console.log(lights_array[9]); //I get on console the value of the index 9 on the console }); console.log(lights_array[9]); //I get an "underfined" here 型号:

Player.h:

Player

Player.m:

#import <Foundation/Foundation.h>
@interface Player : NSObject

@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong) NSMutableArray *answers;

@end

然而,这会显示错误:#import <Foundation/Foundation.h> #import "Player.h" @interface Player () @end @implementation Player - (id)init { if (self = [super init]) { self.answers = [[NSMutableArray alloc] init]; self.image = [UIImage imageNamed:@"defaultProfileImage"]; // <-------------- error } return self; } @end

我如何在模型中使用UIImage?

1 个答案:

答案 0 :(得分:5)

您需要导入

#import <UIKit/UIKit.h>

以便识别UIImage