• 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: Calloc for Cocoa?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Calloc for Cocoa? (From: zauhar <email@hidden>)

  • Prev by Date: NSImage vs. NSBitmapImageRep color differences?
  • Next by Date: How to get energy saving options?
  • Previous by thread: Re: Calloc for Cocoa?
  • Next by thread: Re: Calloc for Cocoa?
  • Index(es):
    • Date
    • Thread