objective-c 类使用举例!
来源:互联网 发布:阿里云流量计费标准 编辑:程序博客网 时间:2024/04/30 08:59
Objective-C中一个简单类的应用:
#inclued <stdio.h>
#include <Foundation/Foundation.h>
//声明类的接口
@interface Container:NSObject
{
int number;
}
-(void)setNumber:(int) n;
-(int)intValue;
@#end
//定义类
@implementation Container
-(void)setNumber:(int)n
{
number=n;
}
-(int) intValue
{
return number;
}
@end
//主函数
int main(void)
{
Container *object=[Container new]; //创建一个对象
[object setNumber:5];
printf("The number is %i\n", [object intValue]);
return 0;
}
输出结果:
The number is 5
0 0
- objective-c 类使用举例!
- Objective-C中的协议使用举例
- Objective-C的基本类方法,举例
- objective-c构造函数举例
- objective-c 中isMemberOfClass的使用举例isKindOfClass的应用举例
- Objective-C类的使用
- 【Objective-C】Objective-C占位符使用
- objective-c 中对于类的使用
- objective-c字符串类NSString的使用
- Objective-c 创建类的使用
- Objective-C类,NSBundle介绍和使用
- Objective-C类,NSUrl介绍和使用
- objective-c 使用文件
- Objective-C使用Category
- objective-c NSMutableDictionary 使用
- Objective-C IMP使用
- objective-c @property 使用
- Objective-C block使用
- C语言中printf()函数格式输出
- C语言原始数据类型
- XCode
- 初学者:介绍NSLog的使用
- 函数指针
- objective-c 类使用举例!
- objective-c构造函数举例
- objective-c 中isMemberOfClass的使用举例isKindOfClass的应用举例
- respondsToSelector instancesRespondToSelector
- 魅族Ubuntu phone系统手机曝光
- C++中ctype函数库
- C++ <vector>入门(1)
- C++ <vector>入门(2)
- 张瑞敏再发狠话:未来硬件不要钱,软件要钱