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

推荐订阅源

I
Intezer
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
N
News | PayPal Newsroom
T
Tenable Blog
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
P
Privacy International News Feed
IT之家
IT之家
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
博客园_首页
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
Martin Fowler
Martin Fowler
NISL@THU
NISL@THU
I
InfoQ
D
DataBreaches.Net
有赞技术团队
有赞技术团队
K
Kaspersky official blog
Security Latest
Security Latest
The Register - Security
The Register - Security
Hugging Face - Blog
Hugging Face - Blog
S
Security @ Cisco Blogs
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AI
AI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic

博客园 - 1901

试用Github Pages iOS设备内存及分辨率 测试显示GitHub的Gist 使用GTMBase64编码解码字符串 颜色转换工具 iOS中获取程序相关的一些目录路径 mac字典词库增加方法 Google的Logo记现代舞先驱玛莎·葛兰姆117周年诞辰-Flash版 关于flash加载flash时的缩放和位置问题 给力壁纸 for mac 【转载】巧用宏定义来简写C,C++代码 Objective-C中的NSObject对象经常使用到的方法 Objective-C属性介绍 应用程序本地化-国家代码介绍(ISO 3166-1) iPhone开发资料 sourceMate2 我在MACOS下常用的软件 【转载】分享一些FLASH开发时用到的工具~ 关于ActionScript3中的事件类强制转换失败的问题
先随便记一下
1901 · 2011-06-15 · via 博客园 - 1901

View Code

/** ===== NSString ===== */
NSString
* string = @"hello, 1901";
NSLog(
@"string retainCount: %lu", [string retainCount]);
// output: string retainCount: 1152921504606846975

NSString
* string = [[NSString alloc] initWithString:@"hello, 1901"];
NSLog(
@"string retainCount: %lu", [string retainCount]);
// output: string retainCount: 1152921504606846975

NSString
* string = [[NSString alloc] initWithFormat:@"%@", @"hello, 1901"];
NSLog(
@"string retainCount: %lu", [string retainCount]);
// output: string retainCount: 1

NSString
* string = [[NSString alloc] initWithUTF8String:"hello, 1901"];
NSLog(
@"string retainCount: %lu", [string retainCount]);
// output: string retainCount: 1

/** ===== NSMutableArray & NSArray ===== */
NSMutableArray
* array = [[NSMutableArray alloc] init];
NSLog(
@"array retainCount: %lu", [array retainCount]);
// array retainCount: 1

NSArray
* array = [[NSArray alloc] init];
NSLog(
@"array retainCount: %lu", [array retainCount]);
// output: array retainCount: 2

NSArray
* array = [[NSArray alloc] initWithObjects:@"hello, 1901", nil];
NSLog(
@"array retainCount: %lu", [array retainCount]);
// output: array retainCount: 1

NSArray
* array1 = [[NSArray alloc] init];
NSLog(
@"array1 retainCount: %p", array1);
NSArray
* array2 = [[NSArray alloc] init];
NSLog(
@"array2 retainCount: %p", array2);
NSArray
* array3 = [[NSArray alloc] init];
NSLog(
@"array3 retainCount: %p", array3);
/*
output:
array1 retainCount: 0x10010d050
array2 retainCount: 0x10010d050
array3 retainCount: 0x10010d050
*/

NSString

* string = [NSString stringWithUTF8String:"hello, 1901"];
NSArray
* array1 = [[NSArray alloc] initWithObjects:string, nil];
NSLog(
@"array1 retainCount: %p", array1);
NSArray
* array2 = [[NSArray alloc] initWithObjects:string, nil];
NSLog(
@"array2 retainCount: %p", array2);
/*
output:
array1 retainCount: 0x1001107c0
array2 retainCount: 0x100110840
*/