Skip to content

Instantly share code, notes, and snippets.

@akio0911
Created May 12, 2009 08:45
Show Gist options
  • Save akio0911/110395 to your computer and use it in GitHub Desktop.
Save akio0911/110395 to your computer and use it in GitHub Desktop.
#import <Cocoa/Cocoa.h>
int main(){
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray * array = [NSArray arrayWithObjects:
[NSNumber numberWithInt:333],
[NSNumber numberWithInt:555],
[NSNumber numberWithInt:444],
[NSNumber numberWithInt:222],
[NSNumber numberWithInt:111],
nil];
int min = [[array valueForKeyPath:@"@min.intValue"] intValue];
int max = [[array valueForKeyPath:@"@max.intValue"] intValue];
NSLog(@"min = %d", min);
NSLog(@"max = %d", max);
NSUInteger minIndex = [array indexOfObject:[NSNumber numberWithInt:min]];
NSUInteger maxIndex = [array indexOfObject:[NSNumber numberWithInt:max]];
NSLog(@"minIndex = %d", minIndex);
NSLog(@"maxIndex = %d", maxIndex);
[pool release];
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment