Objective-C - @property参数
来源:互联网 发布:淘宝总公司投诉电话 编辑:程序博客网 时间:2024/05/01 16:05
@property参数
/* 1.set方法内存管理相关的参数 * retain : release旧值,retain新值(适用于OC对象类型) * assign : 直接赋值(默认,适用于非OC对象类型) * copy : release旧值,copy新值 2.是否要生成set方法 * readwrite : 同时生成setter和getter的声明、实现(默认) * readonly : 只会生成getter的声明、实现 3.多线程管理 * nonatomic : 性能高 (一般就用这个) * atomic : 性能低(默认) 4.setter和getter方法的名称 * setter : 决定了set方法的名称,一定要有个冒号 : * getter : 决定了get方法的名称(一般用在BOOL类型) */@interface Person : NSObject// 返回BOOL类型的方法名一般以is开头@property (getter = isRich) BOOL rich;// @property (nonatomic, assign, readwrite) int weight;// setWeight:// weight// @property (readwrite, assign) int height;@property (nonatomic, assign) int age;@property (retain) NSString *name;@end
@implementation Person@end
Book类
@interface Book : NSObject@end
@implementation Book@end
Student类
#import "Book.h"@interface Student : NSObject@property (retain) Book *book;@property (retain) NSString *name;@end
@implementation Student- (void)dealloc{ [_book release]; [_name release]; [super dealloc];}@end
int main(){ Book *b = [[Book alloc] init]; Person *p = [[Person alloc] init]; p.book = b; NSLog(@"%ld", [b retainCount]); [p release]; [b release]; return 0;}
0 1
- Objective C @property 参数
- Objective-C - @property参数
- Objective-c - @property的参数
- Objective-C学习笔记 @property 参数说明
- 【Objective-C学习-5】@property参数详解
- Objective-C 【@property 的参数问题】
- Objective-C - @property的参数总结
- Objective-c中@property声明时的参数释疑01
- Objective-c中@property声明时的参数释疑02
- Objective-c中@property声明时的参数释疑
- Objective - C基础: 第五天 - 5.@property - 参数详解
- 【Objective-C】类的属性、@property参数、前向声明
- Objective-C内存管理(四)@property相关参数详解
- objective-c中@property的参数分别有何作用?
- 黑马程序员----Objective-C学习笔记之@property参数
- Objective-c - @property的参数strong与weak
- objective-c property
- objective-c property
- 第七章——复用类
- GtkMessageDialog
- 齐次坐标
- default-lazy-init and lazy-init
- Android进阶(二)https请求No peer certificate的解决方法.
- Objective-C - @property参数
- C#中枚举类型的使用
- Scala编程指南(3) 揭示Scala的本质
- 92. Reverse Linked List II
- 理解Certificate、App Id、Identifiers 和 Provisioning Profile
- metasploit - meterpreter commands (linux)
- shell脚本编程(快速排序)
- 15.精灵进阶之给节点添加动作
- R语言中的并行计算——二、搭建R的集群