Search code examples
iphoneobjective-creferencecycle

(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?

Thank you


Solution

  • 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:

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