Last active
December 14, 2015 02:59
-
-
Save jparishy/5018161 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
RACSignal *latest = [RACSignal combineLatest:@[ self.maxWeightTextField.rac_textSignal, self.maxRepsTextField.rac_textSignal ]]; | |
[latest subscribeNext:^(RACTuple *values) { | |
RACTupleUnpack(NSString *maxWeight, NSString *maxReps) = values; | |
CGFloat maxWeightValue = maxWeight.floatValue; | |
NSInteger repIndex = maxReps.integerValue; | |
CGFloat percentages[12] = { | |
1.00f, | |
0.95f, | |
0.90f, | |
0.88f, | |
0.86f, | |
0.83f, | |
0.80f, | |
0.78f, | |
0.76f, | |
0.75f, | |
0.72f, | |
0.70f | |
}; | |
repIndex = MAX(1, repIndex); | |
repIndex = MIN(12, repIndex); | |
CGFloat percentage = percentages[repIndex - 1]; | |
CGFloat oneRepMax = maxWeightValue / percentage; | |
self.oneRepMaxTextField.text = [NSString stringWithFormat:@"%.02f", oneRepMax]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment