Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript running under Cocoa - major speed issue



Steve Cronin wrote:

I have a Cocoa app that has some iPhoto integration.
Since there is no Cocoa API for iPhoto, like there is for
AddressBook, the only way I know to do this is through AppleScript.
Any other ideas here would be appreciated....
[...]
I know it may seem like an AppleScript issue but the shoddy
performance is a ONLY when it is run underneath a Cocoa app so I am
under the impression that there is something Cocoa-related which is
causal.

No idea. AppleScript component memory allocation can be an issue for some things (e.g. recursion depth), but I dunno if it'd be a factor here. The ways of AppleScript are deep and mysterious, not to mention a bit mental too.


At any rate, since you're presumably working in ObjC, I'd suggest bypassing AppleScript altogether and see if that solves the problem for you. e.g. Using objc-appscript:


// To generate glue code: $ osaglue IP iPhoto

#import <Foundation/Foundation.h>
#import "IPGlue.h"

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

IPApplication *iphoto = [[IPApplication alloc] initWithName:@"iPhoto.app"];

NSString *path = @"/Users/has/Pictures/iPhoto Library/Originals/ 2001/21 Apr 2001/My Balcony:plants:tree.jpg";

IPGetCommand *cmd = [[[[iphoto photos] byTest: [[IPIts imagePath] equals: path]] first] get];

id result = [cmd send];

if (result == nil)
NSLog(@"iPhoto raised error: %i (%@)\n", [cmd errorNumber], [cmd errorString]);
else if ([result isEqual: [NSNull null]])
NSLog(@"iPhoto returned no result\n");
else
NSLog(@"iPhoto returned reference: %@\n", result);

[iphoto release];
[pool release];
return 0;
}



No speed problems here:

	[Session started at 2007-10-20 22:26:34 +0100.]
	2007-10-20 22:26:34.954 iphototest[24868] iPhoto returned reference:
			[[IPApp photos] byID: 4294968071]
	iphototest has exited with status 0.


HTH

has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.