CocoaDev

Edit AllPages

(Based on mailing list posts by Nathan Day and Cynthia Copenhagen)

**Q: ** How I can get strings out of some of the fields in the Apple System Profiler.

The Apple Script goes something like:

tell application “Apple System Profiler” get system version as text end tell

What I am not sure of is how to go through a Cocoa script to call the AppleScript command.


**A: ** This is pretty much cut straight out out of a one of my own projects with some small changes, you have to include Carbon. I haven’t found a way to do this sort of thing yet using straight Cocoa.

@implementation NSString (AEDescCreation)

/*

@end


==== To use the AppleScript above use the following code (Cocoa, Mac OS X 10.2 and above):

myCode = @”tell application "Apple System Profiler"\n set sysVersion to get system version as text\n display dialog sysVersion\n end tell”; myAppleScript alloc] initWithSource:[[[NSString stringWithString:myCode]]; [myAppleScript executeAndReturnError:nil]; [myAppleScript release]; }