• 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: David Remahl <email@hidden>
  • Date: Tue, 25 Mar 2003 14:59:11 +0100

_____________________________________________________
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++) {
....
....
}

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?

Your analysis is correct. -count will be sent once per loop iteration. Which may not be a good idea. If it turns out to be a performance problem, then it is better to do:

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

In most cases, it is better to use an enumerator:

NSEnumerator *myArrayEnum = [myArray objectEnumerator];
id currentObj;

while( currentObj = [myArrayEnum nextObject] )
...

_____________________________________________________
2.
how do i change the commented automatic message in project builder?

Search the archives. I don't have the details readily available. <http://cocoa.mamasam.com>

_____________________________________________________
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 a separate implementation of OpenStep. It is OpenSource and runs on many platforms (Unices, Linux). The Foundation layer is reasonably complete, but AppKit still has holes and bugs.

The reason the #import directive is described as deprecated is, I think, that some of the GCC engineers are on a holy war against #import. It has been described as deprecated a long time, but so far still works. it will most likely continue to work in the Apple-modified version of GCC.

On a separate note, there could potentially be a huge difference between different Objective-C class libraries. Think about how much of what we almost consider part of the language that is actually NSObject functionality! And NSClassFromString() and other useful utility functions are also part of the library, not the language.

/ Rgards, David Remahl
_______________________________________________
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: 
 >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: popup buttons and notifications
  • Previous by thread: Re: 3 obj-c/cocoa beginner q's
  • Next by thread: Window resize by blob, not by resize corner
  • Index(es):
    • Date
    • Thread