Re: Wrapping NSTask, setting PATH env var to current user's PATH...
Re: Wrapping NSTask, setting PATH env var to current user's PATH...
- Subject: Re: Wrapping NSTask, setting PATH env var to current user's PATH...
- From: "Clark Cox" <email@hidden>
- Date: Wed, 16 Jan 2008 09:54:41 -0800
On Jan 15, 2008 8:35 PM, John Joyce <email@hidden> 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@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden