First off, let me just get this out of the way: I am not a Obj-C/Cocoa programmer by any stretch of the imagination. I've fumbled my way through this enough to get the result I'm looking for, sans this one issue.
Ok then.
In the below code, I'm simply converting NSData to NSString. This is working.
However, I'm then feeding that NSString result to NSAppleScript:
Again, this is working -- however, only if providing a single line/command (ie. 'tell application "iTunes" to launch')
If I attempt to provide a multi-line command, such as:
Then it attempts to evaluate the string 'as-is', rather than considering the \n as a line-feed.
If i make *msg a static value:
This works fine. So, I figure, it has to be somewhere in the NSString to NSData conversion.
Am I making any sense?
Ok then.
In the below code, I'm simply converting NSData to NSString. This is working.
Code:
NSData *strData = [data subdataWithRange:NSMakeRange(0, [data length] - 2)];
NSString *msg = [[[NSString alloc] initWithData:strData encoding:NSUTF8StringEncoding] autorelease];
However, I'm then feeding that NSString result to NSAppleScript:
Code:
NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:msg];
Again, this is working -- however, only if providing a single line/command (ie. 'tell application "iTunes" to launch')
If I attempt to provide a multi-line command, such as:
Code:
tell application "iTunes"\nactivate\nplaypause\nend tell
Then it attempts to evaluate the string 'as-is', rather than considering the \n as a line-feed.
If i make *msg a static value:
Code:
NSString *msg = @"tell application \"itunes\"\n"
"activate\n"
"playpause";
This works fine. So, I figure, it has to be somewhere in the NSString to NSData conversion.
Am I making any sense?