• 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
Problem with Converting NSApplescript to Scripting Bridge
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with Converting NSApplescript to Scripting Bridge


  • Subject: Problem with Converting NSApplescript to Scripting Bridge
  • From: John MacMullin <email@hidden>
  • Date: Wed, 20 Jun 2012 13:08:45 -0700

The following is the old NSApplescript, which works to create array of mailbox paths.

NSAppleScript *theScript = [[[NSAppleScript alloc]initWithSource:@"tell application \"Mail\"\n set localMailboxes to every mailbox\n end tell\n"]autorelease];
NSDictionary *theError;
NSAppleEventDescriptor *theScriptDescriptor = [theScript executeAndReturnError: &theError];
if (theScriptDescriptor == nil) {
} else {
    NSString *descriptorString;
    int i, u = [theScriptDescriptor numberOfItems];
    for (i = 1; i<=u; i++) {
        descriptorString = [[[theScriptDescriptor descriptorAtIndex:i]paramDescriptorForKeyword:(AEKeyword)'seld']stringValue];
        if (descriptorString == NULL) {
        } else {
            [mailboxes_File addObject:descriptorString];
        }
    }
}

I am trying to substitute Scripting Bridge code with some difficulty.  Iterating through containers, see the following, is slow by comparison to the foregoing NSApplescript.  The container hierarchy involved goes down 6 levels.

-(MailMailbox *)returnTheContainer:(MailMailbox *)incoming_Container
{
    MailMailbox *returnedContainer = [incoming_Container container];
    return returnedContainer;
}

SBElementArray *allMailboxes = [mailApp mailboxes];
int countOfAllMailboxes = [allMailboxes count];
int i;
for (i = 0; i < countOfAllMailboxes; i++) {

    

    NSString *mailboxName = [[allMailboxes objectAtIndex:i]name];
    MailMailbox *returnedContainer = [[allMailboxes objectAtIndex:i]container];

    

    BOOL allContainersFound = NO;
    NSMutableString *returnedPathName = [NSMutableString string];
    [returnedPathName appendString:mailboxName];
    if ([returnedContainer name] == NULL) {
        allContainersFound = YES;
    } else {
        [returnedPathName insertString:@"/" atIndex:0];
        [returnedPathName insertString:[returnedContainer name] atIndex:0];
    }

    

    while (allContainersFound == NO) {
        returnedContainer = [self returnTheContainer:(MailMailbox *)returnedContainer];
        if ([returnedContainer name] == NULL) {
            allContainersFound = YES;
        } else {
            NSString *returnedName = [returnedContainer name];
            [returnedPathName insertString:@"/" atIndex:0];
            [returnedPathName insertString:returnedName atIndex:0];
        }
    }
    [mailboxes_File addObject:returnedPathName];
}


I have looked at the SBOject class and tried the the following with 'seld', which returns null (I could be using it wrong also):
- (SBObject *) propertyWithCode:(AEKeyword)code;

Anyone have any experience in returning the full path directly from the MailMailbox or a way of speeding this up?



Best regards,

John MacMullin
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: AUM MAHA YATRA (Re: 2-way radios and Tibet)
  • Next by Date: Is there a way in Applescript GUI scripting to Simulate Drag and Drop action?
  • Previous by thread: Re: AUM MAHA YATRA (Re: 2-way radios and Tibet)
  • Next by thread: Is there a way in Applescript GUI scripting to Simulate Drag and Drop action?
  • Index(es):
    • Date
    • Thread