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: Can't make ... of <<class >> into type reference




On 16 Nov 2007, at 3:25 PM, Paul Bruneau wrote:

Sorry to self-reply, but I found my problem.

NSScriptClassDescription *containerClassDesc = (NSScriptClassDescription *)
[NSScriptClassDescription classDescriptionForClass:[NSApp class]];
return [[[NSNameSpecifier alloc] initWithContainerClassDescription:containerClassDesc
containerSpecifier:nil key:@"orders"
name:[self pNumber]] autorelease];

You can see I was using my order number (pNumber) in the name: parameter. This did return what appeared to be an OK order object, but if applescript had to go back and reference the order as it did in my example...


set myOrder to first order whose number is orderNumber
	
	customer name of myOrder

...then it couldn't find the order since it used the order number to try to find the order name.


Interestingly, the applescript:
customer name of first scheduled order whose id is orderNumber

...does not even cause the -objectSpecifier method to be called, which it why it always worked, despite the poor form of my code in that method previously.



That's because there's no reason to get the objectSpecifier. Only when this object is used (e.g. to get a property) is the objectSpecifier required.



So what made it work for me was to return the order name in the "name:" parameter in my -objectSpecifier method, but I believe that what I will do is consider to use NSUniqueIDSpecifier with my order number.



The name is typically a string, not a number. See also the note below about uniqueness.


I'm in kind of a funny spot because the primary identifier of an order at my company is the production number or order number, which I think best corresponds to the applescript "name" property, but then we also have an order name such as "Cleveland Water Treatment Plant Job" or similar, so I have to make a decision of which of these properties is the best applescript "name" for an order.

Thanks again everybody, I feel I have a much better handle on this.

You can also have best of both worlds, and access both the unique ID and name property, as well as accessors valueIn<Key>WithName: and valueWith<Key>WithUniqueID: and perhaps an indexed one as well. Though you have to make a choice for your object specifier. This choice could be determined by the following considerations: 1. easy lookup (e.g. through a dictionary), 2. the property (id or name or index) must be unique for the object. So if your order number is unique for the object, the best choice is probably unique ID = production number, and add a name accessor that gives the more descriptive name.


Christiaan


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-implementors mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-implementors/email@hidden

This email sent to email@hidden
References: 
 >Can't make ... of <<class >> into type reference (From: Paul Bruneau <email@hidden>)
 >Re: Can't make ... of <<class >> into type reference (From: Mike Glass <email@hidden>)
 >Re: Can't make ... of <<class >> into type reference (From: Paul Bruneau <email@hidden>)
 >Re: Can't make ... of <<class >> into type reference (From: Christiaan Hofman <email@hidden>)
 >Re: Can't make ... of <<class >> into type reference (From: Paul Bruneau <email@hidden>)
 >Re: Can't make ... of <<class >> into type reference (From: Paul Bruneau <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.