Reputation: 412
Let's assume that i have a method that looks like this.
-(void)doSmth {
NSString *one = [[NSString alloc] initWithFormat:@"%@",someNumber];
NSString *two = [[NSString alloc] initWithFormat:@"%@",someOtherNumer];
[one release];
}
Project was created without ARC. I would like to convert it to ARC.
My question is: will there be leaks after converting to arc?
Thanks
Upvotes: 1
Views: 280
Reputation: 721
if we need to convert to complete project to ARC then Edit ->convert -> to Objective-C ARC
or if u need to convert a particular file then projectNav ->build Phases ->compile source in that particular .m file add -fno-objc-arc
Upvotes: 0
Reputation: 49054
No. The ARC converter will remove the explicit call to release
, and the compiler will automatically insert release calls for both one
and two
at compile time.
End result: no leaks here.
Upvotes: 1
Reputation: 9080
You will have to remove [one release];
as in ARC this generates an error.
With regards to your question, after switching to ARC (and removing the release statement) it will not leak.
Edit: It would probably be better to write the code like this:
NSString *one = [[NSString alloc] initWithFormat@"one"];
or like this:
NSString *one = @"one";
Upvotes: 0