ios developer tiny share-20160804
来源:互联网 发布:网络隐私权的内容 编辑:程序博客网 时间:2024/05/17 14:26
今天讲Objective-C的@property
Properties Control Access to an Object’s Values
Objects often have properties intended for public access. If you define a class to represent a human being in a record-keeping app, for example, you might decide you need properties for strings representing a person’s first and last names.
Declarations for these properties should be added inside the interface, like this:
@interface Person : NSObject @property NSString *firstName;@property NSString *lastName; @end
In this example, the Person class declares two public properties, both of which are instances of the NSString class.
Both these properties are for Objective-C objects, so they use an asterisk to indicate that they are C pointers. They are also statements just like any other variable declaration in C, and therefore require a semi-colon at the end.
You might decide to add a property to represent a person’s year of birth to allow you to sort people in year groups rather than just by name. You could use a property for a number object:
@property NSNumber *yearOfBirth;
but this might be considered overkill just to store a simple numeric value. One alternative would be to use one of the primitive types provided by C, which hold scalar values, such as an integer:@property int yearOfBirth;
0 0
- ios developer tiny share-20160804
- ios developer tiny share-20160628
- ios developer tiny share-20160629
- ios developer tiny share-20160630
- ios developer tiny share-20160701
- ios developer tiny share-20160704
- ios developer tiny share-20160705
- ios developer tiny share-20160706
- ios developer tiny share-20160707
- ios developer tiny share-20160708
- ios developer tiny share-20160711
- ios developer tiny share-20160712
- ios developer tiny share-20160713
- ios developer tiny share-20160714
- ios developer tiny share-20160715
- ios developer tiny share-20160718
- ios developer tiny share-20160719
- ios developer tiny share-20160720
- 文章标题
- HTTP协议详解
- 自架设CDN服务器——智能DNS解析及Squid集群 大型网站加速解决方案
- Codeforces Round #366 (Div. 2) C. Thor (模拟)*
- 分布式服务框架HSF学习
- ios developer tiny share-20160804
- ubuntu 16.04 上安装OpenStack Mitaka (all-in-one):Glance 安装与配置
- 设计模式-----观察者模式
- 显示该程序的路径//C语言
- asp.net小数点四舍五入的方法
- 利用存储过程做mysql循环插入1
- XML报文转JAVA对象-JAVA对象转XML报文
- android横竖屏切换与数据保存
- JS设计模式学习