• 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: How Do I Handle NSNumber Returned in ASObjC?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How Do I Handle NSNumber Returned in ASObjC?


  • Subject: Re: How Do I Handle NSNumber Returned in ASObjC?
  • From: Shane Stanley <email@hidden>
  • Date: Mon, 13 Jun 2016 16:20:38 +1000

On 13 Jun 2016, at 10:04 AM, Shane Stanley <email@hidden> wrote:
>
> So after you have checked for missing value:
>
>  set theResult to theDict's objectForKey:pKeyStr
>  set someArray to current application's NSArray's arrayWithObject:theResult
>  return item 1 of (someArray as list)

If you're lazy, you can also use this:

 set theResult to theDict's objectForKey:pKeyStr
 set someArray to current application's NSArray's arrayWithArray:{theResult}
 return item 1 of (someArray as list)

The difference is that this version will cope with theResult being missing value.

But if you know the class, it's more efficient to just convert directly; this is really a back-stop for when you don't.

--
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


  • Follow-Ups:
    • Re: How Do I Handle NSNumber Returned in ASObjC?
      • From: Jim Underwood <email@hidden>
References: 
 >How Do I Handle NSNumber Returned in ASObjC? (From: Jim Underwood <email@hidden>)
 >Re: How Do I Handle NSNumber Returned in ASObjC? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Best Practice: Lists: Use COPY instead of SET
  • Next by Date: Re: How Do I Handle NSNumber Returned in ASObjC?
  • Previous by thread: Re: How Do I Handle NSNumber Returned in ASObjC?
  • Next by thread: Re: How Do I Handle NSNumber Returned in ASObjC?
  • Index(es):
    • Date
    • Thread