zoukankan      html  css  js  c++  java
  • Objective-c (多输入参数的方法)

      一个方法可能具有多个输入参数。在头文件中,可以定义带有多个输入参数的方法:

      - (void)setIntX:(int)n andSetIntY:(int)d

      下面通过一个例子来说明它的具体用法:

      

     1 #import <Foundation/Foundation.h>
     2 
     3 @interface Test : NSObject{
     4     int _X;
     5     int _Y;
     6 }
     7 @property int _X,_Y;
     8 
     9 - (void)print;
    10 - (void)setX:(int)x andSetY:(int)y;
    11 
    12 @end
    13 
    14 @implementation Test
    15 
    16 @synthesize _X,_Y;
    17 - (void)print{
    18     NSLog(@"x = %i , y = %i",_X,_Y);
    19 }
    20 - (void)setX:(int)x andSetY:(int)y{
    21     _X = x;
    22     _Y = y;
    23 }
    24 
    25 @end
    26 
    27 int main(int argc , const char *argv[]){
    28     @autoreleasepool {
    29         Test *test = [Test new];
    30         [test setX:10 andSetY:10];
    31         [test print];
    32     }
         return 0;
    33 }
  • 相关阅读:
    poj3255,poj2449
    poj2186
    poj3249
    poj3378
    poj3274
    poj1948
    hdu 2181暴搜
    hdu 3342
    hdu 1285
    hdu 1598
  • 原文地址:https://www.cnblogs.com/xiaozhai-1234/p/5248776.html
Copyright © 2011-2022 走看看