Last active
March 25, 2020 15:49
-
-
Save theevo/364d31e8135332cafe93cc4bb24a2bcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.m | |
// Stretch Problem 4.3 - HighestNumberInArray | |
// | |
// Created by theevo on 3/25/20. | |
// Copyright © 2020 Theo Vora. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface PlaygroundClass : NSObject | |
-(id) highestNumber:(NSArray *)inputArray; | |
@end | |
@implementation PlaygroundClass | |
-(id) highestNumber:(NSArray *)inputArray | |
{ | |
NSSortDescriptor *sortOrder = [NSSortDescriptor sortDescriptorWithKey:@"self" ascending:NO]; | |
NSArray *sortedArray = [inputArray sortedArrayUsingDescriptors: [NSArray arrayWithObject: sortOrder]]; | |
return [sortedArray firstObject]; | |
} | |
@end | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
NSArray *array = @[@1,@2,@3]; | |
id i; | |
PlaygroundClass *playground = [[PlaygroundClass alloc]init]; | |
i = [playground highestNumber:array]; | |
NSLog(@"Highest number in %@ is... %@", array, i); | |
NSLog(@"Hello, World!"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment