Skip to content

Instantly share code, notes, and snippets.

@AtomicCat
Created March 14, 2013 23:27
Show Gist options
  • Select an option

  • Save AtomicCat/5166194 to your computer and use it in GitHub Desktop.

Select an option

Save AtomicCat/5166194 to your computer and use it in GitHub Desktop.
Ugly way to call super from a weak self
#import <Foundation/Foundation.h>
#import <objc/objc-runtime.h>
@interface Foo : NSObject
@end
@implementation Foo
- (NSString*)description
{
__weak id weakself = self;
Class class = class_getSuperclass([weakself class]);
struct objc_super weakSuper = { weakself, class };
NSString *string = objc_msgSendSuper(&weakSuper, @selector(description));
return string;
}
@end
int main(int argc, const char * argv[])
{
@autoreleasepool {
Foo *foo = [[Foo alloc] init];
NSLog(@"%@", foo);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment