Reputation: 4084
Extremely basic objective-c question here. I want to call a method from within another method and send a variable from the first method to the second method, but I'm not sure how to handle this with @implementation, etc.
Here is what I want:
-(int) isItFav:(int) favNum
{
// some code
}
- (IBAction)myBar:(UISegmentedControl *)sender
{
// some code
int x = 10;
[isItFav x];
}
This causes as error, as isItFav is an undeclared identifier. Can someone please tell me how to fix this up?
Upvotes: 0
Views: 58
Reputation: 46543
If both myBar:
and isItFav:
are in same class:
int returnedValue = [self isItFav:x];
If in different class, then
int returnedValue = [objectOfClassWhichContainsIsItFavMethod isItFav:x];
This is Objective-C. Please see tutorials and manuals.
Upvotes: 2
Reputation: 9813
[receiverOfCall method:param];
This case: int result = [self isItFav:x];
Upvotes: 0