@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的更多相关文章

  1. iOS中 @synthesize 和 @dynamic 区别

    OC object-c 为了让java的开发者习惯 使用.的操作,所以可以将接口类中的变量 使用@property来声明属性.但是在.h中声明的属性,必须在.m中使用@synthesize或者@dyn ...

  2. @synthesize和@dynamic分别有什么作用?

    @property有两个对应的词,一个是 @synthesize,一个是 @dynamic.如果 @synthesize和 @dynamic都没写,那么默认的就是@syntheszie var = _ ...

  3. @property、@synthesize和dynamic的用法

    原文:  http://blog.csdn.net/hherima/article/details/8622948 @代表“Objective-C”的标志,证明您正在使用Objective-C语言 O ...

  4. 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方 ...

  5. iOS @property、@synthesize和@dynamic

    @property @property的本质: @property = ivar(实例变量) + getter/setter(存取方法); 在正规的 Objective-C 编码风格中,存取方法有着严 ...

  6. synthesize 与dynamic的区别

    官方文档解释: @synthesize will generate getter and setter methods for your property. @dynamic just tells t ...

  7. iOS中 @synthesize 和 @dynamic

    今天写点过时的东西,我记得  这个是xcode 4 那个年代的事情了,没想到有时候大家还会被问到.可能目的就是看看你是从是么时候才开始接触iOS的. 在声明property属性后,有2种实现选择 @s ...

  8. @synthesize 与@dynamic区别

    @synthesize 除非开发人员已经做了,否则由编译器自动生成getter/setter方法. 当开发人员自定义存或取方法时,自定义会屏蔽自动生成该方法. @dynamic 告诉编译器,不自动生成 ...

  9. @synthesize和@dynamic

    @synthesize 除非开发人员已经做了,否则由编译器自动生成getter/setter方法.当开发人员自定义存或取方法时,自定义会屏蔽自动生成该方法. @dynamic 告诉编译器,不自动生成g ...

随机推荐

  1. 1063. Set Similarity (25)

    1063. Set Similarity (25) 时间限制 300 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...

  2. 聚合函数:sum,avg,max,min,count

    group by  分组的使用方法 数学函数:ABS.ceiling.floor.power.round.sqrt.square 练习:

  3. java实现单链表反转

    一.简介 经查阅,主要有两种方法实现链表反转,递归反转法和遍历反转法: 递归: 在反转当前结点之前先反转其后边的结点,即.从尾结点开始逆向反转各个节点的指针域指向: 遍历:从前往后反转各个结点的指针域 ...

  4. CentOS6设置密码过期时间

    #密码过期时间180天chage -M 180 rootchage -l rootchage -M 180 gwchage -l gw

  5. HTML 5 服务器发送事件

    接收 Server-Sent 事件通知 EventSource 对象用于接收服务器发送事件通知: 实例 var source=new EventSource("demo_sse.php&qu ...

  6. Ubuntu 12.04 系统安装极点五笔输入法

    习惯用五笔了,在Ubuntu下安装了下五笔: 下面就实际操作,安装极点五笔输入法! 在终端中执行如下命令: sudo wget http://www.xiit.cn/wp-content/upload ...

  7. Python 基础 - 随机列表最大的两个值

    # -*- coding: utf-8 -*- #author:v def sywmemeda(l): #list 冒泡排序 length = len(l) for i in range(length ...

  8. 今天Apple证书更新,提供 "证书的签发者无效" 解决办法

    首先 下载苹果新证书 developer.apple.com/certificationauthority/AppleWWDRCA.cer 然后在"钥匙串访问"中  "显 ...

  9. SeasLog-An effective,fast,stable log extension for PHP

    github: https://github.com/Neeke/SeasLog @author Chitao.Gao [neeke@php.net] @交流群 312910117 简介 为什么使用S ...

  10. validate 的插件用法

    1.不推荐使用控件方式验证的方式(因为他严重的影响的html代码,也不便于语义化) <input type="text" class="required" ...