Le 6 janv. 2017 à 13:30, Shane Stanley < email@hidden> a écrit : … 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
Hello Shane
In my message posted : jeudi 5 janvier 2017 21:40:22 I used the scheme described above with the handler: on deleteItem:anItem fromList:theList set theArray to current application's NSMutableArray's arrayWithArray:theList theArray's removeObject:anItem set unionOfArrays to (theArray's valueForKeyPath:"@unionOfArrays.self") as list return unionOfArrays end deleteItem:fromList:
On vendredi 6 janvier 2017 11:13:39 I posted a revised version after discovering than the removeObject command was useless. on cleanList:theList set theArray to current application's NSMutableArray's arrayWithArray:theList set unionOfArrays to (theArray's valueForKeyPath:"@unionOfArrays.self") return unionOfArrays as list end cleanList:
And this morning I discovered that as I no longer used removeObject, using a mutable array wasn't required. So the handler become: on cleanList:theList set theArray to current application's NSArray's arrayWithArray:theList return (theArray's valueForKeyPath:"@unionOfArrays.self") as list end cleanList:
Am'I just facing a special case or is (theArray's valueForKeyPath:"@unionOfArrays.self") as list really designed to drop the empty lists ?
I just discovered this interesting behavior when I looked carefully what was displayed in the Log events issued by your ASObjC Explorer.
Maybe it would be useful to return in 10.11 with the old Xcode in which I would find the chapter "NSKeyValueCoding Protocol" named in your Everyday AppleScriptObjC.
Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 16:50:53
|