• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Universal Binary - AppleScript utxt problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Universal Binary - AppleScript utxt problem


  • Subject: Universal Binary - AppleScript utxt problem
  • From: Jerry Brace <email@hidden>
  • Date: Wed, 25 Jan 2006 23:35:28 -0330

I am one step away from making my application Universal. Here is my problem. One of the functions of the app communicates to iTunes via AppleScript to tell it to play a particular playlist.
I have been converting the name of the playlist to AppleScript data to solve any non-Roman character problems when referencing the name in the AppleScript.


For example to play the "Library" playlist in iTunes:

tell application "iTunes"
	play playlist «data utxt004C006900620072006100720079»
end tell

instead of:
tell application "iTunes"
	play playlist "Library"
end tell

This has been working fine until I tried it on an Intel iMac. The error returned is "can't make some data into the expected type" - I assume this means that the data value isn't correctly being translated back to "Library".

I am building the AppleScript in my code and converting the NSString value of the Playlist name by using the following code:

static unichar  UFI_LEFT_DOUBLE_ANGLE_QUOTATION_MARK = 0x00AB; // +
static unichar  UFI_RIGHT_DOUBLE_ANGLE_QUOTATION_MARK = 0x00BB; // ;
static NSString *UFI_APPLESCRIPT_DATA_HEADER = @"data utxt";

@implementation NSString (UFIStringAdditions)

- (NSString *) toUCS2Digits {
    NSMutableString *result = [[[NSMutableString alloc]
initWithCapacity: [self length]] autorelease];
    unsigned int i=0;

    for (i=0; i < [self length]; i++) {
        unichar curr= [self characterAtIndex: i];
        [result appendString: [NSString stringWithFormat: @"X",
curr]];
    }
    return result;
}

- (NSString *) toAppleScriptData {
    return [NSString stringWithFormat: @"%@%@%@%@",
        [NSString stringWithCharacters:
&UFI_LEFT_DOUBLE_ANGLE_QUOTATION_MARK length: 1],
        UFI_APPLESCRIPT_DATA_HEADER,
        [self toUCS2Digits],
        [NSString stringWithCharacters:
&UFI_RIGHT_DOUBLE_ANGLE_QUOTATION_MARK length: 1]];
}

@end


Any help would be great! I've been doing some searching and I have found references to utxt in Universal Binary documents but I have not learned more from it yet.


Jerry

_______________________________________________
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


  • Follow-Ups:
    • Re: Universal Binary - AppleScript utxt problem
      • From: Andrew Farmer <email@hidden>
    • Re: Universal Binary - AppleScript utxt problem
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: I think I have found a big bug in NSBrowser
  • Next by Date: Re: Universal Binary - AppleScript utxt problem
  • Previous by thread: Re: I think I have found a big bug in NSBrowser
  • Next by thread: Re: Universal Binary - AppleScript utxt problem
  • Index(es):
    • Date
    • Thread