开发者

How to call a method from another method with arguments

开发者 https://www.devze.com 2023-04-05 22:56 出处:网络
I want to call another method from the updateButtonPressed method. This is what I tried: -(IBAction) updateButtonPressed{

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

精彩评论

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

关注公众号