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
fly2never
V2EX  ›  iDev

对于内存循环引用的解决, 非 GC 下除了 Weak 还有其他好的办法吗?

  •  
  •   fly2never · 2016-01-15 23:37:14 +08:00 · 2517 次点击
    这是一个创建于 3023 天前的主题,其中的信息可能已经有所发展或是发生改变。
    其实在使用 Objective-C 的时候, 幻想着 Release 下编译器用 ARC, Debug 下编译器自动切换到 GC 模式, 并识别出循环引用供改进
    9 条回复    2016-01-16 14:57:57 +08:00
    Alchemistxxd
        1
    Alchemistxxd  
       2016-01-15 23:53:46 +08:00
    什么情况下的 RC ,是 block 还是其他的。
    fly2never
        2
    fly2never  
    OP
       2016-01-15 23:57:05 +08:00
    @Alchemistxxd 最常见的情况还是 block
    noli
        3
    noli  
       2016-01-16 00:07:50 +08:00
    如果你是想说用某种库或者 GC 以外的办法,使得问题变得看起来比较简化,那么你需要的是 actor 模型 / 协程。
    Alchemistxxd
        4
    Alchemistxxd  
       2016-01-16 00:18:22 +08:00
    @fly2never 如果是 block 我看过一种写法,在 block 最后加上 self = nil ,这样就不需要 weakSelf 了。
    Alchemistxxd
        5
    Alchemistxxd  
       2016-01-16 00:24:46 +08:00
    @Alchemistxxd 我想了下应该是我记错了,这个写法应该只有在 block 最为一个属性的时候才适用。
    Alchemistxxd
        6
    Alchemistxxd  
       2016-01-16 00:26:10 +08:00
    @Alchemistxxd 哎,没法删除答案啊, self = nil 这种傻逼语句都写得出来。。。
    agassi_yzh
        7
    agassi_yzh  
       2016-01-16 10:11:14 +08:00
    PrideChung
        8
    PrideChung  
       2016-01-16 10:47:14 +08:00
    要么用弱引用,要么手动置 nil
    ffffwh
        9
    ffffwh  
       2016-01-16 14:57:57 +08:00 via iPad
    好想法,可以去学术圈找找
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5436 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 06:59 · PVG 14:59 · LAX 23:59 · JFK 02:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.