Search code examples
xcodeapplescriptnsrangeapplescript-objc

How to create NSRange object in AppleScriptObjC


I can't create NSRange object in ASOC. I've googled it but with no luck.

I have tried:
current application's NSMakeRange_({0, 1})
current application's NSMakeRange_({location:0, length:1})
current application's NSRange's NSMakeRange_({location:0,length:1})

please help


Solution

  • Too complicated:

    set range1 to current application's NSMakeRange(0, 1)
    

    And – since C structs can be represented by AppleScript lists or records – still easier:

    set range2 to {location:0, |length|:1}
    

    AppleScriptObjC recognizes the "literal" creation as NSRange