30 lines
862 B
Plaintext
30 lines
862 B
Plaintext
window 1, @"Search a list"
|
|
|
|
void local fn MyEnumeratorCallback( array as CFArrayRef, obj as CFTypeRef, index as NSUInteger, stp as ^BOOL, userData as ptr )
|
|
if ( fn StringIsEqual( obj, userData ) )
|
|
print obj;@" found at index ";index
|
|
*stp = YES// stop enumeration
|
|
end if
|
|
if ( index == 0 ) then print userData;@" not found"
|
|
end fn
|
|
|
|
void local fn DoIt
|
|
CFArrayRef haystack = @[@"Mike",@"Bravo",@"Tango",@"Uniform",@"Golf",
|
|
@"Tango",@"Sierra",@"November",@"Zulu",@"Delta",@"Hotel",@"Juliet"]
|
|
|
|
CFStringRef needle = @"Sierra"
|
|
|
|
NSInteger index = fn ArrayIndexOfObject( haystack, needle )
|
|
if ( index != NSNotFound )
|
|
print needle;@" found at index ";index
|
|
else
|
|
print needle;@" not found"
|
|
end if
|
|
|
|
ArrayEnumerateObjectsWithOptions( haystack, NSEnumerationReverse, @fn MyEnumeratorCallback, (ptr)@"Tango" )
|
|
end fn
|
|
|
|
fn DoIt
|
|
|
|
HandleEvents
|