• 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: 3 obj-c/cocoa beginner q's
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 3 obj-c/cocoa beginner q's


  • Subject: Re: 3 obj-c/cocoa beginner q's
  • From: "Clark S. Cox III" <email@hidden>
  • Date: Tue, 25 Mar 2003 13:51:00 -0500

On Tuesday, Mar 25, 2003, at 13:03 US/Eastern, Mondragon, Ian wrote:

personally, i almost always loop over arrays in the standard way:

---

int count, i;

count = [array count];
for (i = 0; i < count; i++)
{
// whatever
}

---

i found out long ago that, while they're nice, NSEnumerators can kill the
performance of programs when abused...and they're horrible to use when
you're using nested loops in the same types of programs.

just my 2 cents...

If I'm in an area of code where I'm worried about speed, and I expect to iterate over the same array multiple times, then I will do something like this:

unsigned count = [array count];
id *objects = malloc(count * sizeof *objects);
[array getObjects: objects];

for(unsigned i=0; i<count; ++i)
{
... objects[i] ...
}

free(objects);


--
http://homepage.mac.com/clarkcox3/
email@hidden
Clark S. Cox, III
_______________________________________________
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.

  • Prev by Date: Frequency of colors
  • Next by Date: Re: Including headers from a framework?
  • Previous by thread: RE: 3 obj-c/cocoa beginner q's
  • Next by thread: Re: 3 obj-c/cocoa beginner q's
  • Index(es):
    • Date
    • Thread