Skip to content

Instantly share code, notes, and snippets.

@mysteriouspants
Created January 27, 2012 16:10
Show Gist options
  • Select an option

  • Save mysteriouspants/1689532 to your computer and use it in GitHub Desktop.

Select an option

Save mysteriouspants/1689532 to your computer and use it in GitHub Desktop.
descriptionWithLocale:indent: Bug
#import <Foundation/Foundation.h>
@interface C0 : NSObject
@end
@interface C1 : NSObject
@end
@interface C2 : NSObject
@end
int main(int argc, char *argv[]) {
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
NSDictionary* d = [NSDictionary dictionaryWithObjectsAndKeys:
[NSArray arrayWithObject:@"foo!"], @"bar",
[[[C0 alloc] init] autorelease], @"C0",
[[[C1 alloc] init] autorelease], @"C1",
[[[C2 alloc] init] autorelease], @"C2", nil
];
NSLog(@"%@", d);
[p release];
}
@implementation C0
- (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level
{
return @"{\n C0!\n}";
}
- (NSString *)descriptionWithLocale:(id)locale
{
return [self descriptionWithLocale:locale indent:0];
}
- (NSString *)description
{
return [self descriptionWithLocale:nil];
}
@end
@implementation C1
- (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level
{
return @"{\n C1!\n}";
}
- (NSString *)descriptionWithLocale:(id)locale
{
return [self descriptionWithLocale:locale indent:0];
}
@end
@implementation C2
- (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level
{
return @"{\n C2!\n}";
}
@end
2012-01-27 09:08:49.002 Untitled 3[876:707] {
C0 = "{\n C0!\n}";
C1 = "<C1: 0x108b144e0>";
C2 = "<C2: 0x108b17300>";
bar = (
"foo!"
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment