Created
March 26, 2014 19:47
-
-
Save rodericj/9791649 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
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
... | |
... | |
// When the gain changes | |
RACSignal *gainChangeSignal = [RACObserve(self, device.gain) deliverOn:[RACScheduler mainThreadScheduler]]; | |
// cell.auxiliaryLabel.text = @" "; | |
RAC(cell.auxiliaryLabel, text) = [gainChangeSignal map:^id(id value) { | |
// Get the gain lookup table | |
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, | |
NSUserDomainMask, YES) objectAtIndex:0]; | |
NSString *plistPath = [rootPath stringByAppendingPathComponent:@"EQ_Presets.plist"]; | |
if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath]) { | |
plistPath = [[NSBundle mainBundle] pathForResource:@"EQ_Presets" ofType:@"plist"]; | |
} | |
NSArray *lookupTable = [NSArray arrayWithContentsOfFile:plistPath]; | |
lookupTable = [lookupTable subarrayWithRange:NSMakeRange(1, lookupTable.count - 2)]; | |
NSArray *roundedGain = [value map:^id(id obj) { | |
NSNumber *res = @(round([obj floatValue] * 10) / 10); | |
return res; | |
}]; | |
__block NSDictionary *matchingDictionary = nil; | |
[lookupTable enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | |
NSDictionary *gainMap = obj; | |
NSArray *gainArray = @[gainMap[@"d0"], gainMap[@"d1"], gainMap[@"d2"], gainMap[@"d3"], gainMap[@"d4"], gainMap[@"d5"], gainMap[@"d6"], gainMap[@"d7"], gainMap[@"d8"], gainMap[@"d9"]]; | |
if([roundedGain isEqual:gainArray]) { | |
matchingDictionary = obj; | |
stop = YES; | |
} | |
}]; | |
NSLog(@"matching array %@", matchingDictionary); | |
return matchingDictionary[@"name"]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment