惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
V
V2EX
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
K
Kaspersky official blog
S
Secure Thoughts
T
Tenable Blog
Security Latest
Security Latest
The Cloudflare Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
IT之家
IT之家
Latest news
Latest news
The Hacker News
The Hacker News
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
S
Security Affairs
S
Securelist
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
A
About on SuperTechFans

博客园 - 懒蜜蜂

身份证校验规则 [转]扩展jQuery easyui datagrid增加动态改变列编辑的类型 在IIS 5.1/6上以FastCGI方式安装 PHP 如何修复.Net和COM之间枚举名称的问题(续) 通过修改IP/TCP包头伪造IP来与网页进行交互 如何修复.Net和COM之间枚举名称的问题 Compiling and Registering a Type Library Iphone中关于Layer的opaque属性 Xcode配置SVN作为版本控制 Emacs快捷键 Objective C中的札记--字符串连接,@selector中的冒号,时间转换,局部变量 使用GDataXML的设置 IPhone Exec_Bad_Access问题解决办法 C#版的AMF消息封装 Javascript中暂停功能的实现 - 懒蜜蜂 - 博客园 数据库基础理论--关系模式及范式 函数依赖(转) 数据库基础理论之--超键 候选键 主键 拷贝VMWare虚机(XP操作系统)之后网络不通
Objective-C札记二--
懒蜜蜂 · 2010-10-09 · via 博客园 - 懒蜜蜂

1 分类

分类为类定义的扩展提供了一种手段,分类可以访问原始类的实例变量。使用分类需要注意以下几点:

1.1 分类不能添加自身的任何变量,如果需要添加变量,可以考虑创建之类

1.2 分类可以重载该类中的另外一个方法,但是请一定不要尝试这么做。就是不要在分类中去重载(Override)类中的另一个方法。

1.3 一个类可以有很多分类。

1.4 在实现中可以不实现分类中声明的方法。(可以以后实现)

1.5分类也可以实现协议,如:@interface Fraction(Stuff)<NSCopying, NSCoding>

2 协议

协议就是其他语言中所指的接口。Objective-C 2.0在协议中增加了optional关键字,表示此方法是可选择的实现。这个是替换非正式协议的。

非正式协议:它实际就是一个分类,列出了一组方法,但是没有实现它们。有时非正式协议也称作抽象协议。

id<NSCopying, NSCoding> currObj

这个声明告知编译器currObj将包含遵守NSCopying,NSCoding协议的对象,如果不是编译器将会给出警告。

3 类型转换

4 预处理程序

5 作用域