Skip to content

Instantly share code, notes, and snippets.

@0xced
Created September 14, 2012 23:08
Show Gist options
  • Save 0xced/3725528 to your computer and use it in GitHub Desktop.
Save 0xced/3725528 to your computer and use it in GitHub Desktop.
Weak linking with extern NSString *const issue
#import <Social/Social.h>
/* Compiled with iOS 6 SDK
* Social.framework weak linked (Optional)
* Run on iOS 5.1 (simulator and device)
* Output is:
* 0x0
* About to crash
* +++ EXC_BAD_ACCESS +++
*/
int main(int argc, char *argv[])
{
@autoreleasepool
{
NSLog(@"%p", &SLServiceTypeFacebook);
if (&SLServiceTypeFacebook)
{
NSLog(@"About to crash");
NSString *serviceType = SLServiceTypeFacebook; // crashes here with EXC_BAD_ACCESS (code=2, address=0x0)
NSLog(@"Not reached %@", serviceType);
}
}
return 0;
}