• 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: Oscar Morales Vivó <email@hidden>
  • Date: Tue, 25 Mar 2003 14:55:56 +0100

On Tuesday, Mar 25, 2003, at 14:30 Europe/Madrid, Ben Dougall wrote:

_____________________________________________________
1.
this is a bit of code from a book i'm following at the moment. it feels like it might possibly be an inefficient way of doing things. but then i could easily be wrong:

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

Most optimum I can think of (beware of C++isms though). Unless you really need to traverse upwards.

for(int i([myArray count] - 1); i >= 0; --i)
{
...
}

doesn't this mean that the myArray object will get messaged for every for loop execution? in other words if the array has 100 elements myArray is going to get messaged a 100 times? or doesn't that matter? wouldn't defining an int to hold [myArray count] before going into the for loop, and using that int in the for loop arguments, therefore only messaging myArray once, be a better way to do that? or not?

Well, I don't think the compiler can optimize that away, so yes you'd be messaging the object a lot of times. Not a good idea if time-critical code. Can live with it in many cases, though. Most of the time in your program will be spent in system call land unless you do heavy data processing.

3.
what's this website all about?: http://www.gnustep.org/
thing that puzzles me about it is it's all about objective-c and yet there seems to be some contradictions to some fundamental stuff i've read in my recent os x/cocoa/obj-c learning. eg: somewhere in the introduction to objective-c on that site it mentions the #import preprocessor function and says it's deprecated - works but shouldn't be used in new code. ? i get the feeling it's not geared at all towards os x cocoa. but then objective-c's objective-c. shouldn't make too much difference? also it covers NSThings - i sort of had it in mind that NSThings are fairly specific to os x. does this mean that objective-c code written to use NSThings, the cocoa framework, will work on other platforms? if so, which ones?

GNUStep is an open source implementation of the NextStep frameworks, which evolved eventually into Cocoa. They probably have parted ways in a number of issues since it started, but it's a good place to go for easy porting of (relatively simple) Cocoa programs to linux, and for seeing actual code for implementing Appkit and Foundation

Hope that helps.
_______________________________________________
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.

  • Follow-Ups:
    • Re: 3 obj-c/cocoa beginner q's
      • From: Ben Dougall <email@hidden>
References: 
 >3 obj-c/cocoa beginner q's (From: Ben Dougall <email@hidden>)

  • Prev by Date: Re: 3 obj-c/cocoa beginner q's
  • Next by Date: Re: 3 obj-c/cocoa beginner q's
  • 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