José
José

Reputation: 3179

ARC calling non ARC non autoreleased method

I have a program that uses ARC and call in some library methods that are non ARC.

Non ARC Library:

-(NSMutableData*) bar{
    return [[NSMutableData alloc] initWithLength:100];
}

ARC Program:

- (void)foo
{
    NSMutableData* data = [d bar];
}
// Data is leaked

Is possible to avoid data being leaked without change the library method to return an autoreleased object?

When i use this library in Non ARC code i used to call release on data and thus avoid the leak.

Upvotes: 0

Views: 210

Answers (1)

Lithu T.V
Lithu T.V

Reputation: 20021

How about

-(NSMutableData*) bar
{
    return [[[NSMutableData alloc] initWithLength:100] autorelease];
}

Upvotes: 2

Related Questions