V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
yelusiku
V2EX  ›  iDev

Top-level objects in the main nib may leak...

  •  
  •   yelusiku · 2012-03-29 00:42:50 +08:00 · 3183 次点击
    这是一个创建于 4404 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Apple 的 Resource Programming Guide 里有一段说:
    Managing Nib Objects in iOS
    Top-Level Objects
    Objects in the nib file are created with a retain count of 1 and then autoreleased.

    实际上如果是 main nib 里的 top-level objects,是不会被 autorelease 的。这样如果你有一些只在启动时用到的 object 放在 main nib 里实例化,之后想释放掉时只 release 一次的话就 leak 了。除非违反内存管理的规范,对没有 ownership 的对象再 release 一次。

    很奇怪这点没有在文档里提及,不过 Xcode 4.2 以后的 project templates 貌似不提供 main nib 了?
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2408 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:04 · PVG 00:04 · LAX 09:04 · JFK 12:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.