Last active
August 29, 2015 14:21
-
-
Save Qata/dd32d581de555998f77d 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
- (RACSignal *)rac_capturedMetadataObjectsSignal | |
{ | |
[self setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()]; | |
RACSignal *signal = objc_getAssociatedObject(self, _cmd); | |
if (signal != nil) return signal; | |
signal = [[[[self rac_signalForSelector:@selector(captureOutput:didOutputMetadataObjects:fromConnection:) fromProtocol:@protocol(AVCaptureMetadataOutputObjectsDelegate)] reduceEach:^id(AVCaptureOutput * output, NSArray * objects, AVCaptureConnection * connection){ | |
return objects; | |
}] filter:^BOOL(NSArray * objects) { | |
return objects.count; | |
}] map:^id(NSArray * objects) { | |
return objects.firstObject; | |
}]; | |
objc_setAssociatedObject(self, _cmd, signal, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | |
return signal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment