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
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to