Re: if statement causing 32 Byte leak?
Re: if statement causing 32 Byte leak?
- Subject: Re: if statement causing 32 Byte leak?
- From: "Mr. Gecko" <email@hidden>
- Date: Sat, 9 Jan 2010 20:27:33 -0600
So I do not own the object when I get it from string, but I do when I get it from new and that means that I have to release it.
So according to that, this code shouldn't leak, right?
NSMutableString *string = [NSMutableString string];
if (http) {
[string appendString:@"http://"];
} else {
[string appendString:@"https://"];
}
[string appendString:@"example.com/"];
return [NSURL URLWithString:string];
Just seeing if I understand that, it is kinda a lot to remember.
On Jan 9, 2010, at 7:53 PM, Andy Lee wrote:
> On Jan 9, 2010, at 8:35 PM, Mr. Gecko wrote:
>> I just looked and saw that, so one question. Is array, string, and data all the same as new or are those autorelease?
>
> <http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/MemoryMgmt/Articles/mmObjectOwnership.html#//apple_ref/doc/uid/20000043>.
>
> See the bullet points under "Object Ownership Policy". See also the section "Obtaining Objects Using Convenience Methods", which explains the +array, +string, +data, and similarly named methods.
>
> --Andy
>
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden