• 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: Reporting errors from key-value-coding accessors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reporting errors from key-value-coding accessors


  • Subject: Re: Reporting errors from key-value-coding accessors
  • From: Mark Alldritt <email@hidden>
  • Date: Fri, 19 Aug 2005 17:17:16 -0700

Hi There,

> 1) For Cocoa Scripting, the best option is to use a parallel set of
> Cocoa Scripting KVC accessors. This is usually necessary anyway, as
> the semantics of scripted mutation/access can differ from UI or
> internal mutation/access, and separate accessors are the only way to
> enforce read-only properties (although you can mark a property as
> read-only in the dictionary, Cocoa Scripting does not check that).
>
> The parallel accessor just calls the primitive accessor and may also
> perform validation using the validation methods.

He thought of maintaining all these parallel accessors is daunting.  In C++,
one would write templates to machine generate this kind of thing.  Is there
some Objective-C way of (a) generating all this code, and (b) validating
that its all in-sync at compile time?

> To report an error from a scripting accessor, you can call
> [NSScriptCommand currentCommand] and call -setScriptErrorNumber: and -
> setScriptErrorString:.
>
> Ask on the applescript-implementors list if you want a more in-depth
> discussion.
>
> 2) Getters that may find an error that the UI should display to the
> user should make an NSError and display it using NSApp or NSWindow's
> facilities. See <http://developer.apple.com/documentation/Cocoa/
> Conceptual/ErrorHandlingCocoa/index.html>.

How then is a primitive get accessor to know if it should report an error to
the UI?  It would have to somehow detect how it was called.  If the getter
blindly presents an error in the UI, how is the parallel Cocoa Scripting
accessor (or any other KVC client) to know that this has happened and/or
prevent it and report a meaningful error back through Cocoa Scripting?

Cheers
-Mark

------------------------------------------------------------------------
Mark Alldritt                      Late Night Software Ltd.
Phone: 250-380-1725                Script Debugger 3.0 - AppleScript IDE
WEB:  http://www.latenightsw.com/  FaceSpan 4.2 - AppleScript RAD
                                   Affrus 1.0 - Perl Debugging


 _______________________________________________
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

  • Follow-Ups:
    • Re: Reporting errors from key-value-coding accessors
      • From: Bill Cheeseman <email@hidden>
    • Re: Reporting errors from key-value-coding accessors
      • From: Bill Cheeseman <email@hidden>
References: 
 >Re: Reporting errors from key-value-coding accessors (From: Dustin Voss <email@hidden>)

  • Prev by Date: Re: turning the focus ring off on 10.2
  • Next by Date: Re: NSImage opacity or contrast (brightness)
  • Previous by thread: Re: Reporting errors from key-value-coding accessors
  • Next by thread: Re: Reporting errors from key-value-coding accessors
  • Index(es):
    • Date
    • Thread