函数

作者: 众林JS | 来源:发表于2018-11-05 15:58 被阅读0次

    1、函数的声明:

    - (void)eat;//1.1无返回值,也无参数
    - (void)eatWithType:(NSString *)type;//1.2无返回值,有参数
    - (NSString *)eat;//1.3有返回值,无参数
    - (NSString *)eatWithType:(NSString *)type;//1.4有返回值,有参数
    

    2、函数的定义:

    - (void)eat {//1.1无返回值,也无参数
    }
    - (void)eatWithType:(NSString *)type {//1.2无返回值,有参数
    }
    - (NSString *)eat {//1.3有返回值,无参数
    }
    - (NSString *)eatWithType:(NSString *)type{//1.4有返回值,有参数
    }
    

    3、函数的调用:

    [self eat];//1.1无返回值,也无参数
    [self eatWithType:@"fruit"];//1.2无返回值,有参数
    NSString *type = [self eat];//1.3有返回值,无参数
    NSString *type =[self eatWithType:@"fruit"];//1.4有返回值,有参数
    

    相关文章

      网友评论

          本文标题:函数

          本文链接:https://www.haomeiwen.com/subject/ixesxqtx.html