Skip to content

Instantly share code, notes, and snippets.

@Qata
Created May 13, 2015 07:02
Show Gist options
  • Save Qata/20dafd7c306018b4b7bd to your computer and use it in GitHub Desktop.
Save Qata/20dafd7c306018b4b7bd to your computer and use it in GitHub Desktop.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
@weakify(self);
[[[[[[[[self.output.rac_capturedMetadataObjectsSignal filter:^BOOL(AVMetadataMachineReadableCodeObject * codeObject) {
return [codeObject isKindOfClass:[AVMetadataMachineReadableCodeObject class]] && [codeObject.type isEqual:@"org.iso.QRCode"];
}] map:^id(AVMetadataMachineReadableCodeObject * codeObject) {
return codeObject.stringValue;
}].distinctUntilChanged map:^id(NSString * JSONString) {
return [NSJSONSerialization JSONObjectWithData:[[JSONString stringByReplacingOccurrencesOfString:@"\\" withString:@""] dataUsingEncoding:NSASCIIStringEncoding] options:0 error:nil];
}] filter:^BOOL(id value) {
return value != nil && [value isKindOfClass:[NSDictionary class]];
}] map:^id(NSDictionary * info) {
return [FavouriteController tryFavouriteWithInfo:info];
}] filter:^BOOL(id value) {
return value != nil;
}] take:1] subscribeNext:^(FavouriteController * favourite) {
@strongify(self);
[self.navigationController pushViewController:[self favouriteControllerFromFavourite:favourite] animated:YES];
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment