Skip to content

Delegate array should not retain delegates #2

@jasperblues

Description

@jasperblues

You can make a weak reference array as follows:

@implementation NSMutableArray (EngineEventSubscriber)

  • (id)mutableArrayUsingWeakReferences
    {
    return [self mutableArrayUsingWeakReferencesWithCapacity:0];
    }
  • (id)mutableArrayUsingWeakReferencesWithCapacity:(NSUInteger)capacity
    {
    CFArrayCallBacks callbacks = {0, NULL, NULL, CFCopyDescription, CFEqual};
    // We create a weak reference array
    return (__bridge id) (CFArrayCreateMutable(0, capacity, &callbacks));
    }

@EnD

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions