简体   繁体   English

(iphone)循环参考是objectc中的问题吗?

[英](iphone) cycling reference is a problem in objectc?

in class A,
i have B* b;
@property (assign) B* b;

and in class B
i have A* a;
@property (assign) A* a;

is this a problem in objectc? 这是objectc中的问题吗?

Thank you 谢谢

No problem with that. 没问题。

Your objects will have 'weak references' to each other, so there is no memory management issue there. 您的对象之间会有“弱引用”,因此那里没有内存管理问题。

You just have to make sure you don't access deleted memory. 您只需要确保您不访问已删除的内存即可。 For instance in class A: 例如在A类中:

- (void)dealloc
{
    [b setA: nil];

    [super dealloc];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM