smartsanja
smartsanja

Reputation: 4550

How to call a method from another method with arguments

I want to call another method from the updateButtonPressed method. This is what I tried:

-(IBAction) updateButtonPressed{
    [self loadScrollViewWithPage];
} 

But the problem is that the loadScrollViewWithPage method has arguments. That method is like this:

- (void)loadScrollViewWithPage:(int)page {
 }

How can I call this method?

Upvotes: 0

Views: 217

Answers (2)

Brian Gesiak
Brian Gesiak

Reputation: 6978

If I understand correctly, you are wondering how to pass arguments along with messages to objects, is that right? Try:

-(IBAction) updateButtonPressed{
    int foo = 4;
    [self loadScrollViewWithPage:foo]; // a colon, followed by the argument
} 

I suggest you read up on the Objective-C language in general, though.

http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/objectivec/introduction/introobjectivec.html

Upvotes: 4

Ravi Chokshi
Ravi Chokshi

Reputation: 1166

- (IBAction) updateButtonPressed{
   int tempValue=5;
   [self loadScrollViewWithPage:tempValue];
}

Upvotes: 3

Related Questions