|[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]|
On Monday, June 30, 2003, at 12:11 AM, Tomas Zahradnicky wrote:
I was used to use calloc(number_of_items, sizeof(item)) to create an
array of items. Is there some similar thing in Cocoa? The approach
like this seems me quite complex:
Although I don't know if this is exactly what you're after, the
following code works fine:
id *idArray ;
int i ;
idArray = (id *)calloc( 100, sizeof(id) ) ;
for( i = 0 ; i < 10 ; ++i )
idArray = [ [ NSMutableArray alloc ] initWithCapacity:10 ] ;
This array has only ten slots filled, the remaining are nil, which
could be useful in some circumstances. On the other hand, cocoa
provides a way to do that in collections - you just put NSNull at empty
All the best,
Randy J. Zauhar, PhD
Assoc. Prof. of Biochemistry
Director, Graduate Program in Bioinformatics
Dept. of Chemistry & Biochemistry
University of the Sciences in Philadelphia
600 S. 43rd Street
Philadelphia, PA 19104
Discussion after watching Disney's "Lilo & Stitch":
DAD: "But why did the space aliens speak English, as opposed to French,
or Swahili? And why did the one alien speak English with an Eastern
European accent? I don't get it."
CATHERINE (age 7): "That's 'cause you don't have a good cartoon brain."
cocoa-dev mailing list | email@hidden
Do not post admin requests to the list. They will be ignored.
|>Re: Calloc for Cocoa? (From: zauhar <email@hidden>)|
Visit the Apple Store online or at retail locations.
Copyright © 2011 Apple Inc. All rights reserved.