Created
July 6, 2011 15:09
-
-
Save 0xced/1067463 to your computer and use it in GitHub Desktop.
Demonstrates NSURL crash when subclassing, see http://www.openradar.me/9729706
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
#import <Foundation/Foundation.h> | |
@interface MyURL : NSURL | |
@end | |
@implementation MyURL | |
@end | |
void testURL(Class urlClass, NSString *string) | |
{ | |
NSURL *url = [[[urlClass alloc] initWithString:string relativeToURL:[NSURL URLWithString:@"http://www.apple.com"]] autorelease]; | |
NSString *absoluteString = [url absoluteString]; | |
NSLog(@"[%@] %@", urlClass, absoluteString); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
testURL([NSURL class], @"iphone"); | |
testURL([NSURL class], @""); | |
testURL([MyURL class], @"iphone"); | |
testURL([MyURL class], @""); | |
[pool release]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like the mere use of a subclass triggers the bug. The subclass doesn't need any methods in it. You could trim a few lines, keeping the same main() function: