Parsing STDout into an NSDictionary
Parsing STDout into an NSDictionary
- Subject: Parsing STDout into an NSDictionary
- From: Nick Forge <email@hidden>
- Date: Sun, 25 Feb 2007 19:22:22 +1100
I am writing a preferencePane GUI for pmset, to allow configuration
of the "hidden" options of pmset (hard disk sleep timer, wake on lid
open etc.). I have used NSTask to pipe STDout from pmset into an
NSString, and I can make it display on the prefPane with no problems.
Is there any easy way to use an existing class to parse a whitespace
and newline delimited string into an NSDictionary? I'm really just
being lazy, as I'm quite experienced with C and I can easily write a
parsing loop to deal with it, but I just thought I'd check if there's
an easier way to do it in Cocoa.
Here's the format of the data:
Battery Power:
sms 1
hibernatefile /var/vm/sleepimage
acwake 0
sleep 15
halfdim 1
hibernatemode 3
disksleep 10
displaysleep 1
lidwake 1
lessbright 1
AC Power:
womp 1
sms 1
hibernatefile /var/vm/sleepimage
acwake 0
sleep 0
autorestart 0
halfdim 0
hibernatemode 3
disksleep 10
displaysleep 60
lidwake 1
Thanks,
Nick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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