I have problem that im trying to get solve for like week.
My goal is to get variable out of my IBAction, to use for example in -(void)viewDidLoad..
But as far as I am now I can use my variable only in my IBAction..
- (IBAction) changeLat:(NSNumber *)str {
longi = str;
double lop = longi.doubleValue;
NSLog(@"%f",lop);
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog (@"%@",lop);
}
It NSLog shows everything fine in action, but in view did load it doesn’t even recorganize it.
Actually,
IBActionis converted tovoidby the preprocessor. It’s used by Interface Builder as a label that identifies this method as an action able to be related from an IB Object.There’s no way (AFAIK) to use two return types in a function (for example `(IBAction double)´, equivalent to ´(void double)´), but a good practice could be something like this:
Your first declaration of
changeLatseems to be wrong, because as a first parameter you’ll always get the “sender” or “caller” object, related from IB (when called from an action, of course), so, you need to get thestrvalue from a valid place.Cheers.