Last active
August 29, 2015 14:08
-
-
Save OliverLetterer/2e6ab0f8b259a20aa5de to your computer and use it in GitHub Desktop.
firstObject
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
IMP implementation = class_getMethodImplementation([NSArray class], @selector(firstObject)); | |
Dl_info info; | |
if (dladdr(implementation, &info)) { | |
/* | |
info.dli_fname can be | |
* /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation | |
* /private/var/mobile/Containers/Bundle/Application/E68D656E-7B57-4850-B2C9-86E31A053D24/cashier.app/cashier | |
*/ | |
NSString *image = [NSString stringWithCString:info.dli_fname encoding:NSASCIIStringEncoding]; | |
NSParameterAssert([image rangeOfString:@".app"].location == NSNotFound); | |
} |
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
@implementation NSArray (BadThirdPartyImplementation) | |
- (id)firstObject | |
{ | |
return self[0]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment