• 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
Re: Cocoa AppleScript question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa AppleScript question


  • Subject: Re: Cocoa AppleScript question
  • From: Nick Zitzmann <email@hidden>
  • Date: Tue, 17 Jan 2006 16:28:30 -0700


On Jan 17, 2006, at 3:33 PM, Brant Sears wrote:

1. The application has a concept of a set of "friends". To make things simple, let's say each friend only has a first name. Therefore, I don't really care whether the friend is a single string or is a class that has a property that is a string called "name".

You should care. If you want to make objects accessible via AppleScript, they need to be your own custom object type and not a generic model object (NSString, etc.). The reason is because (read on):


The result is that the CurrentFriend property works OK, but trying to retrieve the list results in an error inside the application that apparently has to do with NSScriptObjectSpecifier. I'm looking at that class and I'm a bit baffled at the way it is being used in the "Sketch" example.

How close am I to havin this do what I want?

If you want to make an object scriptable, then the object must respond to the -objectSpecifier method, even if it's read-only. The - objectSpecifier method must return an object that subclasses NSScriptObjectSpecifier; there's a number of built-in object specifiers that you can use. The object specifier needs to be able to uniquely identify an object for AppleScript, so you can use a command like "set theFriend to get friend with name \"Bob\"" to pull out the correct object from the application.


The exceptions are subclasses of NSDocument, NSWindow, and NSApplication; they already implement -objectSpecifier.

Nick Zitzmann
<http://www.chronosnet.com/>


_______________________________________________ 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
References: 
 >Cocoa AppleScript question (From: "Brant Sears" <email@hidden>)

  • Prev by Date: Re: Does NSImage handle Icns Files?
  • Next by Date: Re: Core Data and multithreading (was Re: [Core Data] Improve save performance ?)
  • Previous by thread: Cocoa AppleScript question
  • Next by thread: -[NSTimer invalidate] does not guarantee that the timer won't fire?
  • Index(es):
    • Date
    • Thread