我有以下屬性定義的:在dealloc中釋放的ivars給「指針被釋放沒有分配」的錯誤
@property (nonatomic, retain) NSString *name_;
@property (nonatomic, retain) NSString *profilePicture_;
@property (nonatomic, retain) NSString *username_;
@property (nonatomic, retain) NSString *id_;
,我讓他們開我的init...
這樣的:
-(id)initWithData:(NSDictionary *)data
{
self = [super init];
if (!self) {
return nil;
}
name_ = [data valueForKey:@"full_name"];
profilePicture_ = [data valueForKey:@"profile_picture"];
username_ = [data valueForKey:@"username"];
id_ = [data valueForKey:@"id"];
return self;
}
與以下dealloc
:
-(void)dealloc
{
[name_ release];
[username_ release];
[profilePicture_ release];
[id_ release];
[super dealloc];
}
然而dealloc
給我一封rror:
pointer being freed was not allocated
這是爲什麼?我必須做[[NSString alloc] init...]
或[NSString stringWithString:]
?
什麼是您的Xcode版本?在3.x中有一個問題(不記得一個)... – Kuba 2012-04-28 16:15:29