Skip to content

Instantly share code, notes, and snippets.

@kolyuchiy
Created September 14, 2016 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kolyuchiy/2ab86e90c8a62bd15ed9ef5f71534cc9 to your computer and use it in GitHub Desktop.
Save kolyuchiy/2ab86e90c8a62bd15ed9ef5f71534cc9 to your computer and use it in GitHub Desktop.
+ (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