V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
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 · Mar 29, 2012 · 3767 views
    This topic created in 5156 days ago, the information mentioned may be changed or developed.
    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 了?
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4069 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 04:18 · PVG 12:18 · LAX 21:18 · JFK 00:18
    ♥ Do have faith in what you're doing.