I have an instance variable declared in the implementation file which can be accessed using the property defined by synthesize
@synthesize myProperty
Now, I want to assign this property something inside the Selector event of the MenuItem in cocos2d library. You can think of it as a accessing myProperty in a callback function. For some reason whenever I access the property it says "property is out of scope". So I tried to assigned the access the self.myProperty which worked!!
But now I have a memory leak in self.myProperty. If I release self.myProperty in dealloc then it throws an exception saying that I also have myProperty release.
UPDATE 1: (Code)
NSString *voice;
@property (nonatomic,retain) NSString *voice; @synthesize voice;
-(void)repeatAlphabet:(id)sender
{
*// I cannot access the voice variable in this function.*
[[SimpleAudioEngine sharedEngine] playEffect:[[voice lowercaseString] stringByAppendingString:@".caf"]];
}
-(void) addRepeatButtonOnScreen
{
CCMenuItemImage * menuItem1 =[CCMenuItemImage itemFromNormalImage:@"image1.png"
selectedImage: @"image2.png"
target:self
selector:@selector(repeatAlphabet:)];
CCMenu *menu = [CCMenu menuWithItems:menuItem1,nil];
menu.position = ccp(30, 450);
[self addChild:menu];
}