• 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
Applescript not calling my code?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Applescript not calling my code?


  • Subject: Applescript not calling my code?
  • From: Brad Bumgarner <email@hidden>
  • Date: Wed, 10 May 2006 13:56:23 -0600

In my quest to learn Obj-C and combine this with my knowledge of Applescript, I have been working on an Applescript Studio project that I originally wrote last year. I am adding Address Book functionality to my app. The problem that I am currently having is one of my methods is not being called from the Applescript code. Below are portions of each file involved. Any assistance will be greatly appreciated.

Thanks,
Brad Bumgarner, CTA


AB_handler.h

#import <Cocoa/Cocoa.h>
#import <AddressBook/AddressBook.h>

@interface AB_handler : NSObject

+(NSArray *)createArrayFromAddressBook;
+(NSArray *)searchAdressbookForName:(NSString *)theName;
+(NSArray *)getPhoneNumbersForID:(NSString *)theID; // this is NOT getting called from Applescript
+(NSArray *)getEmailAddressesForID:(NSString *)theID;


@end


AB_handler.m
...
...
+(NSArray *)getPhoneNumbersForID: (NSString *)theID {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

ABAddressBook *AB = [ABAddressBook sharedAddressBook];
ABPerson *person = (ABPerson *)[AB recordForUniqueId:theID]; // record for the person with theID


ABMultiValue *phones; // holds the phone info for person
NSString *phoneNumber; // holds the current phone number
NSString *phoneLabel; // holds the current label
NSMutableArray *phoneNumbers = [[NSMutableArray alloc] init]; // holds the phone #s and labels

if (person) {
phones = [person valueForProperty: kABPhoneProperty];
int count = [phones count];
int i;
for (i = 0; i < count; i++) {
phoneNumber = [phones valueAtIndex: i];
phoneLabel = [phones labelAtIndex: i];
[phoneNumbers addObject: [NSString stringWithFormat: @"%@", phoneNumber]];
[phoneNumbers addObject: [NSString stringWithFormat: @"%@", phoneLabel]];
}
}
if ([phoneNumbers count] > 0) {
[phoneNumbers retain];
[pool release];
return (phoneNumbers);
} else {
[pool release];
return nil;
}
}
...
...



Applescript code
set phoneNumbersForName to (call method "getPhoneNumbersForID:" of class "AB_Handler" with parameter idForName)


-- idForName is an Address Book unique ID string
_______________________________________________
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


  • Prev by Date: Re: C++ gets translated into ObjC? Strange compiler errors...
  • Next by Date: Re: NSKeyedUnarchiver questions
  • Previous by thread: CoreData/problems with "cross-entity observing" / Undo / Redo / Save
  • Next by thread: What is my data source ?
  • Index(es):
    • Date
    • Thread