To learn I have to do everything again and try to not cheat.
Here are some NSArray handlers that return AppleScriptObjC objects.
Its a early version and slow progress.
Some will return NSArray and other could return NSString/NSArray.
New to me is: Key-Value Coding Programming Guide
(**
* AppleScriptObjC Library
*
* CLASS: NSArray
*
* Rev. v0.1
*
* Handlers return AppleScriptObjC Objects.
*)
use framework "Foundation"
(**
* [Type Method]: orderedSetWithArray:
* Creates and returns a set containing a uniqued collection of the objects
* contained in a given array.
*)
-- inputList return orderedSetWithArray as NSArray
on arrayWithRemoveDublicateArray:anArray
return ((current application's NSOrderedSet's orderedSetWithArray:anArray)'s array())
end arrayWithRemoveDublicateArray:
(**
* [Instance Method]: sortedArrayUsingSelector:
* Returns an array that lists the receiving arrayโs elements in
* ascending order, as determined by the comparison method specified
* by a given selector.
*
* valueForKeyPath: @distinctUnionOfObjects.self
* When you specify the @distinctUnionOfObjects operator, valueForKeyPath:
* creates and returns an array containing the distinct objects of the
* collection corresponding to the property specified by the right key path.
*)
-- inputList return arrayWithRemovedDublicateAndSort as NSArray
on arrayWithSortAndRemovedDublicateArray:anArray
return (((current application's NSArray's arrayWithArray:anArray)'s valueForKeyPath:("@distinctUnionOfObjects.self"))'s sortedArrayUsingSelector:"compare:")
end arrayWithSortAndRemovedDublicateArray:
(**
* Same as above, instead use orderedSetWithArray, sortedArrayUsingSelector method.
*)
-- inputList return arrayWithSortAndRemoveDublicateArray as NSArray
on arrayWithSortAndRemoveDublicateArray2:anArray
return ((current application's NSOrderedSet's orderedSetWithArray:anArray)'s array()'s sortedArrayUsingSelector:"compare:")
end arrayWithSortAndRemoveDublicateArray2:
(**
* sortedArrayUsingSelector:"caseInsensitiveCompare:" method.
*)
-- inputList return arrayWithCaseInsensitiveCompareRemoveDublicateArray as NSArray
on arrayWithCaseSortAndRemoveDublicateArray:anArray
return ((current application's NSOrderedSet's orderedSetWithArray:anArray)'s array()'s sortedArrayUsingSelector:"caseInsensitiveCompare:")
end arrayWithCaseSortAndRemoveDublicateArray:
(**
* Key-Value Coding Programming Guide.
* Reference: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/KeyValueCoding/CollectionOperators.html
*)
(**
* valueForKeyPath: @avg.self
* When you specify the @avg operator, valueForKeyPath: reads the property
* specified by the right key path for each element of the collection,
* converts it to a double (substituting 0 for nil values), and computes
* the arithmetic average of these. It then returns the result stored in
* an NSNumber instance.
*)
-- inputList of numbers return arrayWithAverageString as NSString
on arrayWithAverageString:anArray
return ((current application's NSArray's arrayWithArray:anArray)'s valueForKeyPath:"@avg.self")
end arrayWithAverageString:
(**
* valueForKeyPath: @count.self
* When you specify the @count operator, valueForKeyPath: returns the
* number of objects in the collection in an NSNumber instance.
* The right key path, if present, is ignored.
*)
-- inputList of objects return arrayWithCountString as NSString
on arrayWithCountString:anArray
return ((current application's NSArray's arrayWithArray:anArray)'s valueForKeyPath:"@count.self")
end arrayWithCountString:
(**
* valueForKeyPath: @max.self
* When you specify the @max operator, valueForKeyPath: searches among
* the collection entries named by the right key path and returns the
* largest one. The search conducts comparisons using the compare: method,
* as defined by many Foundation classes, such as the NSNumber class.
* Therefore, the property indicated by the right key path must hold
* an object that responds meaningfully to this message. The search
* ignores nil valued collection entries.
*)
-- inputList of numbers return arrayWithMaxString as NSString
on arrayWithMaxString:anArray
return ((current application's NSArray's arrayWithArray:anArray)'s valueForKeyPath:"@max.self")
end arrayWithMaxString:
(**
* valueForKeyPath: @min.self
* When you specify the @min operator, valueForKeyPath: searches among
* the collection entries named by the right key path and returns the
* smallest one. The search conducts comparisons using the compare: method,
* as defined by many Foundation classes, such as the NSNumber class.
* Therefore, the property indicated by the right key path must hold an
* object that responds meaningfully to this message. The search
* ignores nil valued collection entries.
*)
-- inputList of numbers return arrayWithMinString as NSString
on arrayWithMinString:anArray
return ((current application's NSArray's arrayWithArray:anArray)'s valueForKeyPath:"@min.self")
end arrayWithMinString:
(**
* valueForKeyPath: @sum.self
* When you specify the @sum operator, valueForKeyPath: reads the property
* specified by the right key path for each element of the collection,
* converts it to a double (substituting 0 for nil values), and computes
* the sum of these. It then returns the result stored in an NSNumber instance.
*)
-- inputList of numbers return arrayWithSumString as NSString
on arrayWithSumString:anArray
return ((current application's NSArray's arrayWithArray:anArray)'s valueForKeyPath:"@sum.self")
end arrayWithSumString: