• 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
Re: Best Practice for Returning Immutable Objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best Practice for Returning Immutable Objects?


  • Subject: Re: Best Practice for Returning Immutable Objects?
  • From: Karl Moskowski <email@hidden>
  • Date: Tue, 3 Jun 2008 12:16:48 -0400


On 3-Jun-08, at 12:13 PM, Mike Abdullah wrote:

Well this cast is fairly pointless as it makes no change to the data at all. Returning an NSMutableData object from an NSData method is perfectly legitimate as it is a subclass. So you might as well just do:

	return myData;

Really, it's up to you. You can just use the simple option of returning a mutable object, or you can do either of these:

	return [NSData dataWithData:myData];

return [[myData copy] autorelease];


My concern is that the returned object be truly immutable. For now, I'm the only one using the class, but that may change in the future.

----
Karl Moskowski <email@hidden>
Voodoo Ergonomics Inc. <http://voodooergonomics.com/>

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

References: 
 >Best Practice for Returning Immutable Objects? (From: Karl Moskowski <email@hidden>)
 >Re: Best Practice for Returning Immutable Objects? (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Best Practice for Returning Immutable Objects?
  • Next by Date: Re: Best Practice for Returning Immutable Objects?
  • Previous by thread: Re: Best Practice for Returning Immutable Objects?
  • Next by thread: Re: Best Practice for Returning Immutable Objects?
  • Index(es):
    • Date
    • Thread