• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Object Ownership
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Object Ownership


  • Subject: Object Ownership
  • From: Michael Jackson <email@hidden>
  • Date: Sat, 22 May 2010 09:18:22 -0600

Hi all,

First day with Cocoa, so please excuse the basic newbness of this
question. ;) I've read through the documentation about object
ownership and disposal and just wanted to make sure I'm doing
everything correctly in the following method.


- (NSURL *)makeURL:(NSString *)aURLString
{
	NSMutableString *aCopy = [aURLString mutableCopy];

	// do some stuff with aCopy here

	NSURL *aURL = [NSURL URLWithString:aCopy];
	[aCopy release];

	return aURL;
}


The question is whether or not NSURL's URLWithString: is going to
retain aCopy, so it's safe to be released on the next line. I'm just
looking for some confirmation or any pointers from people who are more
used to managing memory than I am.

Thanks,

Michael

--
Michael Jackson
http://mjijackson.com
@mjijackson
_______________________________________________

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

  • Follow-Ups:
    • Re: Object Ownership
      • From: Graham Cox <email@hidden>
    • Re: Object Ownership
      • From: Dave Carrigan <email@hidden>
  • Prev by Date: Re: getting file creation date from NTFS
  • Next by Date: Re: Object Ownership
  • Previous by thread: Re: CATiledLayer Memory Usage
  • Next by thread: Re: Object Ownership
  • Index(es):
    • Date
    • Thread