• 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: Creating a list of numbers from a Contacts group
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a list of numbers from a Contacts group


  • Subject: Re: Creating a list of numbers from a Contacts group
  • From: Shane Stanley <email@hidden>
  • Date: Fri, 06 Jan 2017 23:30:14 +1100

On 6 Jan 2017, at 9:43 pm, Nigel Garvey <email@hidden> wrote:

There's no such method as arrayByRemovingObject:  It
rightly causes an error in Script Editor. And yet it works as I'd
expected in Script Debugger, which is a cause for concern.  :\

As everyone has found at some stage, you can have a terminology conflict if the editor you are using defines an AppleScript term. The word "language" is an example: you can't use it as variable name in Script Editor because it's in SE's dictionary.

A similar thing can happen with classes. Developers can extend classes by adding extra methods, using things called categories and class extensions. They are very common because of the convenience they offer. And once they have been loaded by the application, their methods are all accessible to ASObjC code hosted by the app. 

The arrayByRemovingObject: method is a fairly classic example, simplifying a common job. 

I suppose the removal of empty arrays would have to be something like
this:

 -- Lose any empty arrays and coerce to list.
 set nonEmptyArrayPredicate to current application's class "NSPredicate"'s predicateWithFormat:("self != {}")
 set phoneNumbers to (phoneNumbers's filteredArrayUsingPredicate:(nonEmptyArrayPredicate)) as list

The ASObjC equivalent of what SD is doing would be:

set phoneNumbers to phoneNumbers's mutableCopy()
phoneNumbers's removeObject:{}
-- and then
set phoneNumbers to phoneNumbers as list

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
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: Creating a list of numbers from a Contacts group
      • From: Yvan KOENIG <email@hidden>
References: 
 >Re: Creating a list of numbers from a Contacts group (From: Nigel Garvey <email@hidden>)
 >Re: Creating a list of numbers from a Contacts group (From: Nigel Garvey <email@hidden>)

  • Prev by Date: Re: Creating a list of numbers from a Contacts group
  • Next by Date: Re: Creating a list of numbers from a Contacts group
  • Previous by thread: Re: Creating a list of numbers from a Contacts group
  • Next by thread: Re: Creating a list of numbers from a Contacts group
  • Index(es):
    • Date
    • Thread