我希望这是一个简单的问题,因为我对可可非常陌生。我创建了一个具有UIImageView作为属性的对象。我在另一个程序中设置了该属性,例如在可可中设置参考类型
Bleep* bleep = [[Bleep alloc]init];
bleep.heading = heading;
bleep.distance = distance;
bleep.instanceId = instanceId;
...
bleep.imgView = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, bleepImg.size.width, bleepImg.size.height)];
没有错误,但imgView
是零(0x0)。什么行为会导致这种情况?我正在创建bleep对象,设置值类型很好,但是这个对象似乎不想保存任何东西。
我的课:
@interface Bleep : NSObject {
}
@property float x;
@property float y;
@property float distance;
@property int instanceId;
@property UIImageView* imgView;
@property float heading;
@end
@implementation Bleep
@synthesize x;
@synthesize y;
@synthesize distance;
@synthesize instanceId;
@synthesize heading;
@synthesize imgView;
@end
这将有助于发布你的'@interface'和你的'setImgView:'或'@ synthesize'的相关部分。 – Anomie 2011-04-16 03:57:41