Previous | Index | Next |
List manipulation methods
indexesOfItem:inArray:inverting:
Returns list of indexes where item is found; inverting true returns indexes where the item is not found. Indexes are zero-based.
+ (NSArray *)indexesOfItem:(id)theItem inArray:(NSArray *)listOrArray inverting:(BOOL)invertFlag
theItem = the item to find
listOrArray = a list or array
invertFlag = whether to list the matching item indexes, or all other indexes
An array of integers
Version 1.0.0
use scripting additions
use framework "Foundation"
use script "BridgePlus"
load framework
set listOrArray to {1, 2, 3, 2, 4, 2, 5, 3}
set theItem to 2
set theResult to current application's SMSForder's indexesOfItem:theItem inArray:listOrArray inverting:false
ASify from theResult
--> {1, 3, 5}
theResult as list
--> {1, 3, 5}
set theResult to current application's SMSForder's indexesOfItem:theItem inArray:listOrArray inverting:true
ASify from theResult
--> {0, 2, 4, 6, 7}
theResult as list
--> {0, 2, 4, 6, 7}