Re: is Shane's advice being collated?
Re: is Shane's advice being collated?
- Subject: Re: is Shane's advice being collated?
- From: Shane Stanley <email@hidden>
- Date: Fri, 21 Nov 2014 22:26:08 +1100
On 21 Nov 2014, at 9:39 pm, 2551 <email@hidden> wrote:
>
> Nope, that would introduce a bug into the code in at least two obvious cases:
>
> i. the method can be used to return the result of any NSTask. Making Shane's amendment will fail if the result is an NSArray or something else that doesn't respond to the length selector.
Huh? You can have your script return a list or record or whatever you like -- your method is always going to return you a string (or nil). That's one of the limitations of that whole NSTask approach.
> ii. even if the intended result was an NSString, if the result was null, Shane's amendment would likely cause a crash/
This is true. It should probably check replyData and return whatever you think is appropriate for no result. But the whole thing is just getting more complicated. Unpacking an NSAppleEventDescriptor is starting to look appealing.
> I've used and tested this method in a lot of different situations, and it's pretty robust.
Except that it sent you on a wild goose-chase over NSString and equality. It might be robust, but it's still not returning what the script is returning (thought that's easily fixed), it's still limited to strings, it's still unnecessarily complicated, and it's still going to be slower with all that extra overhead.
> Any operations you want to do on the result (like stripping a string), need to be done at the caller's end.
And there's more code, and more chances to introduce bugs.
Look, I can think of lots of cases where this would be fine. Because you'd be performing operations on the result, you'd probably clean up the linefeed anyway.
But let's get back to where this started. You said: "at least from my own POV, ASObjC doesn't seem to have any natural place where it excels on its own". I'm just pointing one obvious case relevant to the way you say you work, thinking you might have missed it. Feel free to keep ignoring it. At this point I'm pointing it out more for sake of any lurkers who want to write less Objective-C and more AppleScript.
--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>
_______________________________________________
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