I am working on my first iPhone game and am wondering how to return a value from a function when this first function calls a second function? The functions returns bools.
Here is some sample code:
// This is sample calls to inrect functions:
[menuButton inrect:point] // Calls the first function which calls second function
[menuButton inrect:point:0.5] // No problem because calls the second function directly
Here are functions:
- (BOOL) inrect:(CGPoint)_point{
[self inrect:_point:0]; //call second function with offset of 0
return 0; //How do I return the value of the above call?
}
- (BOOL) inrect:(CGPoint)_point:(float)offset{
if (_point > 0 && offset > 1) {
return YES;
}
if (_point < 0 && offset < 1) {
return YES;
}
return NO;
}
There is no problem when I call the second function directly, but when calling the first function, which in turns calls the second function, how do I properly return the value of the second function back to the first function so it can return it to where it was called from.
Thanks
I’m not sure I’m getting you. Just return it: