Objective-C Passing a variable to another IBAction
- by StuR
This works fine:
NSString *myVariable;
- (IBAction) doFirstAction {
myVariable = @"123456789";
}
- (IBAction) doSecondAction {
NSLog(@"%@",myVariable);
}
However, if I do this (substituting the @"123456789" for some code which returns the same value ie "123456789") I cannot access the value in doSecondAction.
NSString *myVariable;
- (IBAction) doFirstAction {
myVariable = [imageNode getAttributeName:@"value"];
}
- (IBAction) doSecondAction {
NSLog(@"%@",myVariable);
}
Any clue as to why I cant access myVariable outside of doFirstAction?