Skip navigation.
 
mlRe: Wrapping NSTask, setting PATH env var to current user's PATH...
FROM : Clark Cox
DATE : Wed Jan 16 18:54:41 2008

On Jan 15, 2008 8:35 PM, John Joyce <<email_removed>> wrote:
> Thanks in advance for any replies.
> Looks like I finally found what I was looking for. Mostly it is a
> matter of doing some assuming on common PATH locations to search for
> and then set things up programatically. Looks like I will likely also
> need to programatically look for paths stored
> in .profile, .bash_login, etc... as part of life dealing with NSTask
> tools that may not be default OS X installed tools.
>
> I think my big stumbling block was switching my thinking from Ruby to
> Objective-C object messaging and method syntax. They're not terribly
> far apart conceptually, but the code does read a bit differently.
> The other stumbling block was simply getting used to Cocoa & Obj-C
> conventions and terminology for collections. Simply getting used to
> things like NSDictionary and the Cocoa/Obj-C way of KVC. In Ruby it's
> usually easy arrays and hashes.
>
> One thing I'm still kind of struggling to internalize is
> NSEnumerator. In Ruby, many classes inherit/mix in enumerating
> methods that are very common to its collection types of classes and
> become very core to the way things are very convenient there.
> Can anyone suggest a good tutorial/reference/example code on
> iterating with NSEnumerator and such in Cocoa? ( I hope I'm not
> asking in the wrong list here ).


There isn't much to using NSEnumerator, as it's a very simple class.
Just call -nextObject repeatedly. Each time you call it, you will be
given a subsequent object in the collection being enumerated. When
-nextObject returns nil, you know you've enumerated over the entire
collection.

NSEnumerator *enumerator = [someCollection objectEnumerator];
id element;

while(element = [enumerator nextObject]) {
  /*do something with element here*/
}

--
Clark S. Cox III
<email_removed>

Related mailsAuthorDate
mlWrapping NSTask, setting PATH env var to current user's PATH... John Joyce Jan 16, 03:11
mlRE: Wrapping NSTask, setting PATH env var to current user's PATH... John Joyce Jan 16, 05:35
mlRe: Wrapping NSTask, setting PATH env var to current user's PATH... Clark Cox Jan 16, 18:54