@synthesize vs. @dynamic
@synthesize will generate getter and setter methods and corresponding instance variable for your property. @dynamic just tells the compiler that the instance variable, the getter and setter methods are implemented not by the class itself but somewhere else (like the superclass or will be provided at runtime).
Uses for @dynamic are e.g. with subclasses of NSManagedObject (CoreData) or when you want to create an outlet for a property defined by a superclass that was not defined as an outlet (the property of the subclass is just used as an interface. Its actual variable and implement is in the super class):
Super class:
@property (nonatomic, retain) NSButton *someButton;
...
@synthesize someButton;
Subclass:
@property (nonatomic, retain) IBOutlet NSButton *someButton;
...
@dynamic someButton;
参考:http://stackoverflow.com/questions/1160498/synthesize-vs-dynamic-what-are-the-differences
@synthesize vs. @dynamic的更多相关文章
- iOS中 @synthesize 和 @dynamic 区别
OC object-c 为了让java的开发者习惯 使用.的操作,所以可以将接口类中的变量 使用@property来声明属性.但是在.h中声明的属性,必须在.m中使用@synthesize或者@dyn ...
- @synthesize和@dynamic分别有什么作用?
@property有两个对应的词,一个是 @synthesize,一个是 @dynamic.如果 @synthesize和 @dynamic都没写,那么默认的就是@syntheszie var = _ ...
- @property、@synthesize和dynamic的用法
原文: http://blog.csdn.net/hherima/article/details/8622948 @代表“Objective-C”的标志,证明您正在使用Objective-C语言 O ...
- iOS 内存管理-copy、 retain、 assign 、readonly 、 readwrite、nonatomic、@property、@synthesize、@dynamic、IB_DESIGNABLE 、 IBInspectable、IBOutletCollection
浅谈iOS内存管理机制 alloc,retain,copy,release,autorelease 1)使用@property配合@synthesize可以让编译器自动实现getter/setter方 ...
- iOS @property、@synthesize和@dynamic
@property @property的本质: @property = ivar(实例变量) + getter/setter(存取方法); 在正规的 Objective-C 编码风格中,存取方法有着严 ...
- synthesize 与dynamic的区别
官方文档解释: @synthesize will generate getter and setter methods for your property. @dynamic just tells t ...
- iOS中 @synthesize 和 @dynamic
今天写点过时的东西,我记得 这个是xcode 4 那个年代的事情了,没想到有时候大家还会被问到.可能目的就是看看你是从是么时候才开始接触iOS的. 在声明property属性后,有2种实现选择 @s ...
- @synthesize 与@dynamic区别
@synthesize 除非开发人员已经做了,否则由编译器自动生成getter/setter方法. 当开发人员自定义存或取方法时,自定义会屏蔽自动生成该方法. @dynamic 告诉编译器,不自动生成 ...
- @synthesize和@dynamic
@synthesize 除非开发人员已经做了,否则由编译器自动生成getter/setter方法.当开发人员自定义存或取方法时,自定义会屏蔽自动生成该方法. @dynamic 告诉编译器,不自动生成g ...
随机推荐
- VMwareTools 安装(VMware Player)
1. VMare Tools 按钮是灰化的,需要对虚拟机做如下设置:(在虚拟机没有启动的状态下进行) 1)Player(P)->管理->虚拟机设置->CD/DVD 选择:使 ...
- div居中
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- SQL servcer 时间日期函数、数据类型转换
1.时间日期函数 2.数据类型转换 3.习题 建立两个表,一个部门表,一个人员表.部门:部门的编号,部门的名称,部门的职责.人员:人员的编号,姓名,年龄,性别,cid所属部门
- js封装
方法一: function Tetrio(singleW){ if(singleW == undefined){ singleW = 18; } this.x = 0; this.y = 0;} Te ...
- javascript中的删除方法
可能呢再开发的过程中呢使用的不是很多,但是碰上呢可以注意下 1.比如: var x = 10; delete x; console.log(x); 结果是多少,是10,不是异常也不是undefined ...
- for memory long term update
xargs是一条Unix和类Unix操作系统的常用命令.它的作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题. #例如,下面的命令: rm `find /path -type f ...
- 3_STL算法
1.常用遍历算法1.1 for_each for_each(v1.begin(),v1.end(),show); void show(int &n) //回调函数的入口地址 { cout &l ...
- IOS第二天多线程-05NSOperationQueue 暂停,和恢复队列任务
*********** #import "HMViewController.h" @interface HMViewController () <UITableViewDel ...
- jquery 同id使用指针寻找具体每个id的值
this来判断<script language="javascript"> function t(obj) { alert(obj.value); } </scr ...
- scala基础语法(变量,数据类型,函数)
一:常量与变量 1.常量 2.两种变量定义方式(严格与不严格) 3.Float注意点 3.注意点 变量名后加上: 类型首字母是大写 4.占位符_ 但是需要制定类型 5.scala数据类型 6.其他类型 ...