Re: Calloc for Cocoa?
Re: Calloc for Cocoa?
- Subject: Re: Calloc for Cocoa?
- From: zauhar <email@hidden>
- Date: Mon, 30 Jun 2003 11:06:18 -0400
Sorry , forgot the index on idArray[i] in that last example.
It IS Monday...
On Monday, June 30, 2003, at 10:29 AM, zauhar wrote:
On Monday, June 30, 2003, at 12:11 AM, Tomas Zahradnicky wrote:
Hello,
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
positions.
All the best,
Randy
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
Phone: (215)596-8691
FAX: (215)596-8543
E-mail: email@hidden
Web: http://tonga.usip.edu/zauhar
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
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
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
Phone: (215)596-8691
FAX: (215)596-8543
E-mail: email@hidden
Web:
http://tonga.usip.edu/zauhar
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
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.