Re: sort, cut and paste
Re: sort, cut and paste
- Subject: Re: sort, cut and paste
- From: Uli Kusterer <email@hidden>
- Date: Sat, 28 Oct 2006 11:36:47 +0200
Am 26.10.2006 um 20:49 schrieb email@hidden:
I need to perform some sorting, cutting and pasting in my Cocoa app
on ASCII
files. No - not the cutting and pasting found under the edit menu,
but like
the commands used at the command line. In "Building Cocoa
Applications" from
O'Reilly, I noticed they created a small app with lex and yacc and
then linked it
with the Cocoa application with a pipe from within Project Builder/
Xcode.
I don't remember offhand what the cut/paste command-line tools do
exactly, but if you want to split strings at fixed offsets or on a
certain delimiter, you can use NSString's -substringWithRange: resp. -
componentsSeparatedByString:, and there's a similar method in
NSString or NSArray to paste strings together again.
Once you have an array of the strings you need (though you'll
probably get rows, not columns, so depending on what you're doing you
may have to do some swapping, but that's easy), you can sort them
just fine.
Don't use NSTask if that works for you. Apart from the overhead
launching of processes and passing around the text cause, there's
other considerations, like escaping special characters, about which I
blogged a while ago: http://zathras.de/angelweb/x2005-03-10b.htm
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
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