• 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: copy versus arrayWithArray:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: copy versus arrayWithArray:


  • Subject: Re: copy versus arrayWithArray:
  • From: "stephen joseph butler" <email@hidden>
  • Date: Fri, 18 Aug 2006 09:37:29 -0500

2006/8/18, Greg Hurrell <email@hidden>:
Except that the two statements aren't equivalent. A copy of a mutable
array yields another mutable array (the poster said that "orig" is a
mutable array). Conversely, NSArray's arrayWithArray: will return an
immutable array (which is arguably better in this case because in
many cases immutable arrays are faster than mutable ones).

Are you sure? This is in F-Script,

a := NSMutableArray array

a addObject:'test 1'

a addObject:'test 2'

a addObject:'test 3'

a
NSCFArray {'test 1', 'test 2', 'test 3'}

b := a copy

b
NSCFArray {'test 1', 'test 2', 'test 3'}

b addObject:'test 4'

NSInternalInconsistencyException: *** -[NSCFArray addObject:]: mutating method sent to immutable object _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >copy versus arrayWithArray: (From: Eric Scharff <email@hidden>)
 >Re: copy versus arrayWithArray: (From: Nir Soffer <email@hidden>)
 >Re: copy versus arrayWithArray: (From: Greg Hurrell <email@hidden>)

  • Prev by Date: Re: copy versus arrayWithArray:
  • Next by Date: Re: Receiving actions from WebViews
  • Previous by thread: Re: copy versus arrayWithArray:
  • Next by thread: Re: copy versus arrayWithArray:
  • Index(es):
    • Date
    • Thread