Re: 3 obj-c/cocoa beginner q's
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.