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



This will not work. You want it to be contained by the app, you probably did not even expose your app's delegate for scripting. So use containerSpecifier = nil and containerClassDescription = [NSClassDescription classDescriptionForClass:[NSApplication class]].

About your code, usually the "id" property is a unique id. This does not seem to be the case, so it's better not to use "id" for this name, but something like "number" or "order number" or something.

Also the reason it did not work is as Mike says, you're giving a location specifier, not an object specifier. Sometimes you can fix this by forcing an evaluation, either by using an intermediate variable or inserting a "get" command. So I think this should work:

set myOrder to (get first scheduled order whose id is orderNumber)

Christiaan

On 15 Nov 2007, at 10:44 PM, Paul Bruneau wrote:

Thanks, Mike, I really like your idea and I will double check my - objectSpecifier method. In the meantime, here it is:

- (NSScriptObjectSpecifier *)objectSpecifier
{
unsigned index = [[[NSApp delegate] orders] indexOfObjectIdenticalTo:self];
if (index == NSNotFound)
{
return nil;
}

NSScriptObjectSpecifier *containerRef = [[NSApp delegate] objectSpecifier];
return [[[NSIndexSpecifier allocWithZone:[self zone]]
initWithContainerClassDescription:[containerRef keyClassDescription]
containerSpecifier:containerRef key:@"orders" index:index] autorelease];

}


It was copied and modified from Sketch which was done at the limit of my understanding after having read the Object Specifiers section of the docs repeatedly so it may be flawed.

But still I am bothered that it seems to be returning a valid order in the first script for use in this line:
customer name of first scheduled order whose id is orderNumber

But then it fails when the response is put into myOrder.

On Nov 15, 2007, at 4:26 PM, Mike Glass wrote:

I'm just guessing here, and maybe Matt or Christiaan or someone with more experience can set me straight if I'm wrong, but it seems like "first scheduled order whose id is orderNumber" is returning a row number (12) instead of the object you're expecting (scheduled order). Make sure you're implementing - (NSScriptObjectSpecifier *)objectSpecifier; on your Order class, and that it returns an NSScriptObjectSpecifier subclass that is useful to you (we use NSUniqueIDSpecifier because each of our CD objects has a unique id).

-
Mike Glass
email@hidden

On Nov 15, 2007, at 4:08 PM, Paul Bruneau wrote:

I want to thank everyone for helping me with my enumeration problem including the tips on the utilities.

I would like to trouble you for one more piece of assistance. I do not do so lightly--I have spent several hours trying to find the cause for this problem.

I am working on implementing applescript into my Cocoa application which is in development and I have it successfully getting and setting properties of the main objects (orders). I have also successfully implemented the core "make" command with properties which is very handy for having FileMaker create new objects in my app.

But I am being stumped by what seems like it ought to me such a simple script. First, this works:

tell application "Scheduler"
	activate
	
	set orderNumber to "24777"
	
	customer name of first scheduled order whose id is orderNumber
	
end tell

It returns the name of the customer.

But this next script fails with "Scheduler got an error: Can't make customer name of <<class >> 12 into type reference. Here is the script:

tell application "Scheduler"
	activate
	
	set orderNumber to "24777"
	
	set myOrder to first scheduled order whose id is orderNumber
	
	customer name of myOrder
	
end tell

For the life of me, I can't figure out why it fails when I try to use the variable myOrder.

I am concerned that in the error message the <<class >> part seems to have a blank class. That does not make sense to me but I don't know where to look.

I have posted my .sdef to this handy code review site:
http://objc.pastebin.com/m5da48033
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-implementors mailing list (Applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-implementors/ email@hidden


This email sent to email@hidden

_______________________________________________ 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>)



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.