Created
September 14, 2016 15:42
-
-
Save kolyuchiy/2ab86e90c8a62bd15ed9ef5f71534cc9 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
+ (UIImage *)imageWithBlock:(UIImage *(^)(void))block { | |
MRLazyImage *lazyImage = [(MRLazyImage *)[self alloc] initWithBlock:block]; | |
return (UIImage *)lazyImage; | |
} | |
- (UIImage *)image { | |
if (!_image && self.block) { | |
_image = self.block(); | |
self.block = nil; | |
} | |
return _image; | |
} | |
- (void)forwardInvocation:(NSInvocation *)invocation { | |
invocation.target = self.image; | |
[invocation invoke]; | |
} | |
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel { | |
return [self.image methodSignatureForSelector:sel]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment