-
-
Save constellationsoftware/6369137 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @interface RefactorTest : NSObject | |
| @property (strong, nonatomic) NSMutableArray *arrayPayloadValue; | |
| - (id) initWithArray:(NSArray *) thearray; | |
| // this should return the sum of the array values | |
| - (NSNumber *) sum; | |
| // this should return the average of the array values | |
| - (NSNumber *) average; | |
| @end |
This file contains hidden or 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
| @implementation RefactorTest | |
| - (id) initWithArray:(NSArray *) thearray { | |
| self.arrayPayloadValue = [thearray mutableCopy]; | |
| return self; | |
| } | |
| - (NSNumber *) sum { | |
| NSArray *tosum = [self.arrayPayloadValue copy]; | |
| int *sum calloc(1,sizeof(int)); | |
| NSNumber *endsum; | |
| for (NSNumber *i in tosum) { | |
| *sum = *sum + [i intValue]; | |
| } | |
| return @(sum); | |
| } | |
| - (NSNumber *) average { | |
| NSAssert("This must be implemented"); | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment