Are you facing with "out of scope" message when you debug your code and after the class allocation you call the constructor method passing some initialization variables?
I'll show you a wrong and a correct method respectively:
-(void)initWithName:(NSString*)n andNickName(NSString*)n2
{
// this is a wrong method.
self.name = n;
self.nickName = n2;
}
--
-(void)initWithName:(NSString*)n andNickName(NSString*)n2
{
// this is a correct method.
self = [super init];
self.name = n;
self.nickName = n2;
[self retain];
}
If you don't know about "retain and memory management" click here.
Solved.
No comments:
Post a Comment