• 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: AppleScriptObjC oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScriptObjC oddity


  • Subject: Re: AppleScriptObjC oddity
  • From: Chris Page <email@hidden>
  • Date: Sun, 12 Jul 2015 21:44:50 -0700


On Jul 12, 2015, at 8:31 PM, Shane Stanley <email@hidden> wrote:

On 13 Jul 2015, at 12:48 pm, Chris Page <email@hidden> wrote:

2. "screens" and "frame" are properties, not functions, so you shouldn't use "()" with them.

Really?

Really. Don't do it. It's superfluous, and it conflicts with AppleScript semantics:

on foo()
42
end foo

set x to foo -- x is «handler foo»
set y to x() -- y is 42
set z to foo() -- z is 42

If you have an Objective-C method that returns a function, you won't be able to invoke it with "foo()".

Here's Steve's code and how it looks logged in ASObjC Explorer:

0000.001 [4] set ss to current application's NSScreen's screens()
  --> (NSArray) {(NSScreen) <NSScreen: 0x600000865540>, (NSScreen) <NSScreen: 0x60000026e840>}
0000.001 [5] set leftScreenBox to (ss's objectAtIndex:1)'s frame()
  --> {origin:{x:-2560.0, y:0.0}, size:{width:2560.0, height:1440.0}}

The resulting NSRect is bridged to a record, as at least I would expect.

If you want to convert an NSRect to a record, be explicit and use "… as record". As you well know, since you filed a bug report about it, there is no intentional, supported means to generically coerce Objective-C objects to AppleScript objects without knowing what type you want to coerce it to. That this works is a complete surprise to me, as the saying goes.

-- 
Chris Page
The other, other AppleScript Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: AppleScriptObjC oddity
      • From: Shane Stanley <email@hidden>
References: 
 >Re: AppleScriptObjC oddity (From: Chris Page <email@hidden>)
 >Re: AppleScriptObjC oddity (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: AppleScriptObjC oddity
  • Next by Date: Re: AppleScriptObjC oddity
  • Previous by thread: Re: AppleScriptObjC oddity
  • Next by thread: Re: AppleScriptObjC oddity
  • Index(es):
    • Date
    • Thread