入门Objective-C语言需要适应
来源:互联网 发布:王自如 知乎 编辑:程序博客网 时间:2024/06/02 02:47
#import <Foundation/Foundation.h>@interface Foo : NSObject //类的声明所有类都继承自NSObject{}-(int) f:(int)x;-(float) g:(int)x :(int)y; //参数的标签名称可以省略,但扔要有冒号@end@implementation Foo //类的实现-(int) f:(int)x{ NSLog(@"x is %d",x); return 1;}-(float) g:(int)x :(int)y{ NSLog(@"x is %d , y is %d",x, y); return 1.0;}@end@interface Foo2 : NSObject{}-(int) add:(int)v1 :(int)v2;@end@implementation Foo2-(int) add:(int)v1 :(int)v2{ return v1+v2;} @endint main (int argc, const char * argv[]){ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; //ARC NSLog (@"hello world");//输出字符串 Foo *lu = [[Foo alloc] init]; //初始化构造一个对象 int ha = 4, he = 10; [lu f:ha]; //调用对象的方法 [lu g:he :ha]; Foo2 *an = [[Foo2 alloc] init]; NSLog(@"%d", [an add:he :ha]); //直接输出对象方法的返回值 [pool drain]; //释放ARC return 0;}
0 0
- 入门Objective-C语言需要适应
- 初学Objective-C语言需要了解的星星点点
- 由C++入门Objective-C——Objective C 的语言特性
- Objective-C入门
- Objective-C入门
- 转:Objective-C入门
- Objective-C 入门
- objective-c 入门诗
- Objective-C 入门
- Objective-C入门了解
- Objective-C 入门
- objective-c入门
- objective-c 入门tip
- Objective-C 快速入门
- 学习Objective-C: 入门
- Objective-C入门知识
- Objective-C入门
- Objective-C 入门
- repo
- JVM内存的设置(解决eclipse下out of memory问题)
- getClass().getResourceAsStream VS getClass().getClassLoader().getResourceAsStream
- 【数位DP】【HDU 2089】不要62
- Matlab中的fzero和fsolve函数
- 入门Objective-C语言需要适应
- Ubuntu下安装pdf 阅读器
- 2.1-4习题总结
- Ubuntu 12.04 LTS , 编译Android 源代码遇到的若干问题记录
- metaq的msgid生成规则
- 堆排序(最大堆进阶)--【算法导论】
- 设计模式之工厂方法模式
- 存储控制器的多路径机制
- solr4.5配置ik分词器