Re: NSPipe / NSTask ls -> Array
Re: NSPipe / NSTask ls -> Array
- Subject: Re: NSPipe / NSTask ls -> Array
- From: Jeffrey J Barbose <email@hidden>
- Date: Sun, 16 Jul 2006 19:43:51 -0700
On 16-jul-2006, at 02:06, email@hidden wrote:
Dear Prach, Dear Jerry,
thanks for your help!
I have to execute an "ls" on "/dev/tty.*" and use the results
as options in an NSPopupMenu.
Is there a reason you can't just do something like this:
NSArray *devContents = [[NSFileManager defaultManager]
directoryContentsAtPath:@"/dev"];
NSPredicate *ttyPredicate = [NSPredicate predicateWithFormat:@"SELF
beginswith 'tty.'"];
NSArray *ttys = [devContents
filteredArrayUsingPredicate:ttyPredicate];
Um, i guess the only reason against using your solution
was: i didn't know it's possible this way.
This is absolutely a hallmark of Cocoa development.
You'll find some Cocoa APIs to call and get an enormous amount of
work done in 5 lines...
...then, 6 months later when you're more of a Cocoa pro, you'll see
that the API guys already thought of the use-case you had, and you
can rewrite your function in one call.
Trust.
Just started yesterday with Objective-C/Cocoa and tried to dive in :-)
So maybe the best way in using this list is not letting other users
review solutions, but rather asking which way the problem is solved in
best style...
I'm afraid (this is my next step, after choosing my tty. device) i
should not use NSTask / NSPipe with "cat /dev/tty.jaddajadda" either?
(i know about iokit, but i am really trying to avoid it, the solution
with just choosing the /dev/tty.* devices instead of asking iokit with
1000 lines of code "could you please show me the devices?" seems to be
much easier for me).
So may i ask what's the correct direction here?
Thanks in advance,
Dominik
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40godofbiscuits.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden