Re: NSArray - waste of time?
Re: NSArray - waste of time?
- Subject: Re: NSArray - waste of time?
- From: John Stiles <email@hidden>
- Date: Wed, 25 Apr 2007 15:09:30 -0700
NS objects are always going to be more heavyweight than their plain C
counterparts. They also allow for much more functionality. For
example, NSNumbers can be in collections like arrays and sets, and
can be passed as an NSObject or id—raw ints can't. NSArray supports
refcounts, bounds checking, and includes very convenient abstractions
like enumerators and methods like "makeObjectsPerformSelector"; C
arrays are less convenient.
Welcome to the world of object-oriented programming ;) You lose in
terms of raw performance, but win big in terms of programmer
flexibility and convenience. In a world of quad-core multi-gigahertz
processors, it's a good tradeoff.
On Apr 25, 2007, at 2:02 PM, Fen Soares wrote:
There is also the footprint to consider, surely? A C-style array is
likely
to be much smaller than an NSArray of objects, particularly in the
case of
primitive data types such as floats vs NSNumber objects.
On 14/04/07, Scott Stevenson <email@hidden> wrote:
On Apr 14, 2007, at 11:26 AM, William Squires wrote:
> What advantage does using an NSArray/NSMutableArray have over using
> an ordinary C-style static/dynamic 'array'?
I think a better question is why you would want to use a C-style
array if you have don't have to.
NSArray is safer, easier to use, is natively supported throughout
Cocoa, and is bridged to the prodecural CFArrayRef structure. The
implementation is also available through Apple's open source
repositiory.
If you absolutely need to use every ounce of raw speed, you should
use a C-style array. Otherwise, make things easy on yourself and use
NSArray. You also might find this interesting:
http://ridiculousfish.com/blog/archives/2005/12/23/array/
- Scott
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40googlemail.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40blizzard.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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