2014/10/20学习心得--简单的Person程序
来源:互联网 发布:网络安全工程师pdf 编辑:程序博客网 时间:2024/05/22 09:03
1 ,学习基本OC语言的程序编写:
(1),先在Command Line Tool中创建PersonTest工程;
(2),在main.m文件中添加person类;
(3),在person.h中编写实例变量,及方法的声明:
#import <Foundation/Foundation.h>
@interface Person :NSObject
//声明事例变量
{
int identify;
int age;
}
//声明方法
-(id)initWithAge:(int)_age identify:(int)_identify;
-(int)getAge;
-(int)getIdentify;
-(void)setAge:(int)_age;
@end
#import <Foundation/Foundation.h>
#import "Person.h"
int main(int argc,constchar * argv[])
{
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
}
Person *person=[[Personalloc]initWithAge:16identify:45678];
NSLog(@"person.age is %d",[persongetAge]);
int age=30;
[personsetAge:age];
NSLog(@"the new person.age is %d",[persongetAge]);
[personsetAge:++age];
NSLog(@"the second person.age is %d",[persongetAge]);
NSLog(@"the first person.identify is %d",[persongetIdentify]);
return0;
}
(6),显示结果:
2014-10-20 10:43:04.953 PersonTest[793:303] Hello, World!
2014-10-20 10:43:04.954 PersonTest[793:303] person.age is 16
2014-10-20 10:43:04.954 PersonTest[793:303] the new person.age is 30
2014-10-20 10:43:04.954 PersonTest[793:303] the second person.age is 31
2014-10-20 10:43:04.954 PersonTest[793:303] the first person.identify is 45678
Program ended with exit code: 0
- 2014/10/20学习心得--简单的Person程序
- [20140101_Examploe04]简单的Person类
- 简单的学习心得
- 简单易懂的SSDT学习心得
- 一个telnet程序的学习心得!
- (八)简单排序-对象的插入排序(person)
- Person p=new Person()的感悟
- 关于OR-Mapping的学习心得体会
- 关于OR-Mapping的学习心得体会
- 关于OR-Mapping的学习心得体会
- SQLJ的简单示例及一点学习心得
- greenDAO学习心得,实现简单的CRUD
- yarn学习心得 yarn上的程序开发
- 第一个android 程序的学习心得
- 2014 4 10学习心得
- Struts1.2.4学习心得!(-)
- MFC-最简单的MFC程序
- person
- java正则表达式
- C++之命名空间
- android 的service一点了解
- 个人Android学习demo集
- SQL Server 2005数据库修改名字
- 2014/10/20学习心得--简单的Person程序
- Linux ./configure --prefix 命令是什么意思?
- Ubuntu下JDK的下载、安装、配置与卸载
- A Very Long String
- 中小企业知识产权政策该如何破题
- 完全卸载oracle11g步骤
- 短信api服务数据接口
- Ubuntu下配置sendmail
- H.264(片及片头语法)