开发者

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 th开发者_高级运维at the loadScrollViewWithPage method has arguments. That method is like this:

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

How can I call this method?


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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜