diff --git a/MNCoder/IntermediateObjects/MNAttributedString.m b/MNCoder/IntermediateObjects/MNAttributedString.m index c73c05b..c848435 100644 --- a/MNCoder/IntermediateObjects/MNAttributedString.m +++ b/MNCoder/IntermediateObjects/MNAttributedString.m @@ -62,7 +62,7 @@ -(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super init])) { _string = [[aDecoder decodeObjectForKey:@"string"] copy]; _attributes = [[aDecoder decodeObjectForKey:@"attributes"] copy]; - __substituteClasses = [[NSMutableSet setWithCapacity:0] retain]; + __substituteClasses = [NSMutableSet setWithCapacity:0]; [self registerSubstituteClass:[MNASParagraphyStyle class]]; [self registerSubstituteClass:[MNASGlyphInfo class]]; @@ -90,7 +90,7 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { -(id)initWithAttributedString:(NSAttributedString *)string { if ((self = [super init])) { - __substituteClasses = [[NSMutableSet setWithCapacity:0] retain]; + __substituteClasses = [NSMutableSet setWithCapacity:0]; [self registerSubstituteClass:[MNASParagraphyStyle class]]; [self registerSubstituteClass:[MNASGlyphInfo class]]; @@ -134,7 +134,7 @@ -(NSAttributedString *)attributedString { #if TARGET_OS_IPHONE // translate for iOS range = [[self class] _rangeFromRangeDictionaryItem:[dict objectForKey:kMNAttributedStringAttributeRangeKey]]; - CFAttributedStringSetAttributes((CFMutableAttributedStringRef)aString, CFRangeMake(range.location, range.length) , (CFDictionaryRef)attributeToInsert, false); + CFAttributedStringSetAttributes((__bridge CFMutableAttributedStringRef)aString, CFRangeMake(range.location, range.length) , (__bridge CFDictionaryRef)attributeToInsert, false); #else // translate for Mac @@ -142,7 +142,7 @@ -(NSAttributedString *)attributedString { #endif } - return [aString autorelease]; + return aString; } -(Class)_substituteClassForObject:(void *)object { @@ -167,11 +167,10 @@ -(void)_buildIntermediateRepresentationFromString:(NSAttributedString *)string { NSUInteger idx = 0; for (NSString *key in attrs) { - subsituteClass = [self _substituteClassForObject:key]; + subsituteClass = [self _substituteClassForObject:(__bridge void*)key]; if (subsituteClass) { - subsituteObject = [[subsituteClass alloc] initWithAttributeName:key value:[attrs objectForKey:key] range:range forAttributedString:string]; + subsituteObject = [[subsituteClass alloc] initWithAttributeName:key value:(__bridge void*)[attrs objectForKey:key] range:range forAttributedString:string]; [attributes insertObject:[self _dictionaryForAttributes:subsituteObject range:range] atIndex:([attributes count]-1)]; - [subsituteObject release], subsituteObject = nil; } else { NSLog(@"Attribute not translated ->> (%@): %@", key, [attrs objectForKey:key]); @@ -184,18 +183,10 @@ -(void)_buildIntermediateRepresentationFromString:(NSAttributedString *)string { }]; [attributes removeLastObject]; - [_attributes release], _attributes = nil; _attributes = [attributes copy]; } --(void)dealloc { - [__substituteClasses release], __substituteClasses = nil; - [_string release], _string = nil; - [_attributes release], _string = nil; - [super dealloc]; -} - -(NSDictionary *)_dictionaryForAttributes:(NSDictionary *)attrs range:(NSRange)aRange { NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:3]; [dict setObject:[[self class] _rangeStringFromRange:aRange] @@ -255,11 +246,11 @@ +(void)setLossless:(BOOL)lossless { #pragma mark - MNCIntermediateObject Protocol -(id)initWithSubsituteObject:(void *)object { - return [self initWithAttributedString:(id)object]; + return [self initWithAttributedString:(__bridge id)object]; } +(BOOL)isSubstituteForObject:(void *)object { - return [(id)object isKindOfClass:[NSAttributedString class]]; + return [(__bridge id)object isKindOfClass:[NSAttributedString class]]; } diff --git a/MNCoder/IntermediateObjects/MNColor.m b/MNCoder/IntermediateObjects/MNColor.m index 5ae2ac0..c5d5777 100644 --- a/MNCoder/IntermediateObjects/MNColor.m +++ b/MNCoder/IntermediateObjects/MNColor.m @@ -94,14 +94,14 @@ -(NSString *)description { #pragma mark - MNCIntermediateObject Protocol -(id)initWithSubsituteObject:(void *)object { - return [self initWithColor:object]; + return [self initWithColor:(__bridge id)object]; } +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return [(id)object isKindOfClass:[UIColor class]]; + return [(__bridge id)object isKindOfClass:[UIColor class]]; #else - return [(id)object isKindOfClass:[NSColor class]]; + return [(__bridge id)object isKindOfClass:[NSColor class]]; #endif } diff --git a/MNCoder/IntermediateObjects/MNFont.m b/MNCoder/IntermediateObjects/MNFont.m index 22e926f..0da1d95 100644 --- a/MNCoder/IntermediateObjects/MNFont.m +++ b/MNCoder/IntermediateObjects/MNFont.m @@ -48,11 +48,6 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeFloat:self.size forKey:@"size"]; } --(void)dealloc { - [_fontName release], _fontName = nil; - [super dealloc]; -} - #pragma mark - Platform specific representation #if TARGET_OS_IPHONE @@ -104,14 +99,14 @@ -(NSString *)description { #pragma mark - MNCIntermediateObject Protocol -(id)initWithSubsituteObject:(void *)object { - return [self initWithFont:(id)object]; + return [self initWithFont:(__bridge id)object]; } +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return [(id)object isKindOfClass:[UIFont class]]; + return [(__bridge id)object isKindOfClass:[UIFont class]]; #else - return [(id)object isKindOfClass:[NSFont class]]; + return [(__bridge id)object isKindOfClass:[NSFont class]]; #endif } diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASCharacterShape.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASCharacterShape.m index e225f6b..eedb80c 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASCharacterShape.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASCharacterShape.m @@ -36,7 +36,7 @@ @implementation MNASCharacterShape -(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super init])) { - _shapeType = [[aDecoder decodeObjectForKey:@"shapeType"] retain]; + _shapeType = [aDecoder decodeObjectForKey:@"shapeType"]; } return self; @@ -50,15 +50,15 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return [(id)object isEqualToString:(NSString *)kCTGlyphInfoAttributeName]; + return [(__bridge id)object isEqualToString:(NSString *)kCTGlyphInfoAttributeName]; #else - return [(id)object isEqualToString:NSGlyphInfoAttributeName]; + return [(__bridge id)object isEqualToString:NSGlyphInfoAttributeName]; #endif } -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { if ((self = [super init])) { - _shapeType = [(NSNumber *)object retain]; + _shapeType = (__bridge NSNumber *)object; } return self; } @@ -71,10 +71,4 @@ -(NSDictionary *)platformRepresentation { #endif } --(void)dealloc { - [_shapeType release], _shapeType = nil; - [super dealloc]; -} - - @end diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASFont.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASFont.m index 76d1323..29fdd2d 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASFont.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASFont.m @@ -36,11 +36,11 @@ @implementation MNASFont -(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super init])) { - _fontName = [[aDecoder decodeObjectForKey:@"fontName"] retain]; + _fontName = [aDecoder decodeObjectForKey:@"fontName"]; _size = [[aDecoder decodeObjectForKey:@"size"] floatValue]; - _baseLineAdjustment = [[aDecoder decodeObjectForKey:@"baselineAdjustment"] retain]; - _obliqueness = [[aDecoder decodeObjectForKey:@"obliqueness"] retain]; - _expansion = [[aDecoder decodeObjectForKey:@"expansion"] retain]; + _baseLineAdjustment = [aDecoder decodeObjectForKey:@"baselineAdjustment"]; + _obliqueness = [aDecoder decodeObjectForKey:@"obliqueness"]; + _expansion = [aDecoder decodeObjectForKey:@"expansion"]; } @@ -59,9 +59,9 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return (([(id)object isEqualToString:(NSString *)kCTFontAttributeName]) || ([(id)object isEqualToString:NSFontAttributeName])); + return (([(__bridge id)object isEqualToString:(NSString *)kCTFontAttributeName]) || ([(__bridge id)object isEqualToString:NSFontAttributeName])); #else - return [(id)object isEqualToString:NSFontAttributeName]; + return [(__bridge id)object isEqualToString:NSFontAttributeName]; #endif } @@ -81,19 +81,18 @@ -(id)_valueForAttribute:(NSString *)attributeName atRange:(NSRange)theRange forA -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { if ((self = [super init])) { #if TARGET_OS_IPHONE - CTFontDescriptorRef fontDesc; if ([MNAttributedString hasUIKitAdditions]) { if ([attributeName isEqualToString:NSFontAttributeName]) { - UIFont *theFont = (UIFont *)object; + UIFont *theFont = (__bridge UIFont *)object; NSNumber *baselineOffset = [self _valueForAttribute:NSBaselineOffsetAttributeName atRange:range forAttributedString:string]; if (!baselineOffset) baselineOffset = [NSNumber numberWithFloat:0.0]; CFStringRef desckeys[] = { kCTFontNameAttribute, kCTFontBaselineAdjustAttribute, kCTFontSizeAttribute }; - CFTypeRef descvalues[] = { (CFStringRef)theFont.fontName, (CFNumberRef)baselineOffset, (CFNumberRef)[NSNumber numberWithFloat:theFont.pointSize] }; + CFTypeRef descvalues[] = { (__bridge CFStringRef)theFont.fontName, (__bridge CFNumberRef)baselineOffset, (__bridge CFNumberRef)[NSNumber numberWithFloat:theFont.pointSize] }; CFDictionaryRef descDict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&desckeys , (const void **)&descvalues, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); fontDesc = CTFontDescriptorCreateWithAttributes(descDict); @@ -106,29 +105,26 @@ -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range: fontDesc = CTFontCopyFontDescriptor(object); } - _fontName = CTFontDescriptorCopyAttribute(fontDesc, kCTFontNameAttribute); + _fontName = (__bridge NSString *)CTFontDescriptorCopyAttribute(fontDesc, kCTFontNameAttribute); - _baseLineAdjustment = CTFontDescriptorCopyAttribute(fontDesc, kCTFontBaselineAdjustAttribute); + _baseLineAdjustment = (__bridge NSNumber *)CTFontDescriptorCopyAttribute(fontDesc, kCTFontBaselineAdjustAttribute); CFNumberRef pointSize = CTFontDescriptorCopyAttribute(fontDesc, kCTFontSizeAttribute); - _size = [(NSNumber *)pointSize floatValue]; + _size = [(__bridge NSNumber *)pointSize floatValue]; CFRelease(pointSize); CFDictionaryRef traits = CTFontDescriptorCopyAttribute(fontDesc, kCTFontTraitsAttribute); - _obliqueness = CFDictionaryGetValue(traits, kCTFontSlantTrait); - _expansion = CFDictionaryGetValue(traits, kCTFontWidthTrait); - - CFRetain(_obliqueness); - CFRetain(_expansion); - + _obliqueness = (__bridge NSNumber *)CFDictionaryGetValue(traits, kCTFontSlantTrait); + _expansion = (__bridge NSNumber *)CFDictionaryGetValue(traits, kCTFontWidthTrait); + CFRelease(traits); CFRelease(fontDesc); #else - _fontName = (NSString *)CTFontCopyPostScriptName(object); + _fontName = (__bridge NSString *)CTFontCopyPostScriptName(object); - _size = ((NSFont *)object).pointSize; + _size = ((__bridge NSFont *)object).pointSize; _baseLineAdjustment = [[self _valueForAttribute:NSBaselineOffsetAttributeName atRange:range forAttributedString:string] copy]; _obliqueness = [[self _valueForAttribute:NSObliquenessAttributeName atRange:range forAttributedString:string] copy]; @@ -138,13 +134,13 @@ -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range: // set default values if they are not filled in if (!_baseLineAdjustment) - _baseLineAdjustment = [[NSNumber numberWithFloat:0.0] retain]; + _baseLineAdjustment = [NSNumber numberWithFloat:0.0]; if (!_obliqueness) - _obliqueness = [[NSNumber numberWithFloat:0.0] retain]; + _obliqueness = [NSNumber numberWithFloat:0.0]; if (!_expansion) - _expansion = [[NSNumber numberWithFloat:0.0] retain]; + _expansion = [NSNumber numberWithFloat:0.0]; } return self; @@ -153,29 +149,29 @@ -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range: -(NSDictionary *)platformRepresentation { #if TARGET_OS_IPHONE - CFStringRef traitskeys[] = { kCTFontSlantTrait, kCTFontWidthTrait }; - CFTypeRef traitsvalues[] = { (CFNumberRef)self.obliqueness, (CFNumberRef)self.expansion }; + CFStringRef traitskeys[] = { kCTFontSlantTrait, kCTFontWidthTrait }; + CFTypeRef traitsvalues[] = { (__bridge CFNumberRef)self.obliqueness, (__bridge CFNumberRef)self.expansion }; - CFDictionaryRef traitsDict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&traitskeys , (const void **)&traitsvalues, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - - CFStringRef desckeys[] = { kCTFontNameAttribute, kCTFontBaselineAdjustAttribute, kCTFontTraitsAttribute }; - CFTypeRef descvalues[] = { (CFStringRef)self.fontName, (CFNumberRef)self.baseLineAdjustment, traitsDict }; - - CFDictionaryRef descDict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&desckeys , (const void **)&descvalues, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes(descDict); - CFRelease(traitsDict); - CFRelease(descDict); - + CFDictionaryRef traitsDict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&traitskeys , (const void **)&traitsvalues, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + + CFStringRef desckeys[] = { kCTFontNameAttribute, kCTFontBaselineAdjustAttribute, kCTFontTraitsAttribute }; + CFTypeRef descvalues[] = { (__bridge CFStringRef)self.fontName, (__bridge CFNumberRef)self.baseLineAdjustment, traitsDict }; + + CFDictionaryRef descDict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&desckeys , (const void **)&descvalues, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes(descDict); + CFRelease(traitsDict); + CFRelease(descDict); + CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, self.size, NULL); CFStringRef keys[] = { kCTFontAttributeName }; CFTypeRef values[] = { font }; - NSDictionary *platformRepresentation = (NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + NSDictionary *platformRepresentation = (__bridge_transfer NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFRelease(descriptor); CFRelease(font); - - return [platformRepresentation autorelease]; + + return platformRepresentation; #else NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:4]; @@ -187,7 +183,7 @@ -(NSDictionary *)platformRepresentation { [dict setObject:self.expansion forKey:NSExpansionAttributeName]; CFStringRef desckeys[] = { kCTFontNameAttribute }; - CFTypeRef descvalues[] = { (CFStringRef)self.fontName }; + CFTypeRef descvalues[] = { (__bridge CFStringRef)self.fontName }; CFDictionaryRef descDict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&desckeys , (const void **)&descvalues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes(descDict); @@ -196,7 +192,7 @@ -(NSDictionary *)platformRepresentation { CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, self.size, NULL); CFRelease(descriptor); - [dict setObject:(NSFont *)font forKey:NSFontAttributeName]; + [dict setObject:(__bridge NSFont *)font forKey:NSFontAttributeName]; CFRelease(font); return dict; @@ -204,13 +200,4 @@ -(NSDictionary *)platformRepresentation { #endif } --(void)dealloc { - [_fontName release], _fontName = nil; - [_baseLineAdjustment release], _baseLineAdjustment = nil; - [_obliqueness release], _obliqueness = nil; - [_expansion release], _expansion = nil; - [super dealloc]; -} - - @end \ No newline at end of file diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASForegroundColor.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASForegroundColor.m index 0b72a71..df2cc97 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASForegroundColor.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASForegroundColor.m @@ -36,7 +36,7 @@ @implementation MNASForegroundColor -(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super init])) { - _color = [[aDecoder decodeObjectForKey:@"color"] retain]; + _color = [aDecoder decodeObjectForKey:@"color"]; } return self; @@ -50,9 +50,9 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return (([(id)object isEqualToString:(NSString *)kCTForegroundColorAttributeName]) || ([(id)object isEqualToString:NSForegroundColorAttributeName])); + return (([(__bridge id)object isEqualToString:(NSString *)kCTForegroundColorAttributeName]) || ([(__bridge id)object isEqualToString:NSForegroundColorAttributeName])); #else - return [(id)object isEqualToString:NSForegroundColorAttributeName]; + return [(__bridge id)object isEqualToString:NSForegroundColorAttributeName]; #endif } @@ -60,14 +60,14 @@ -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range: if ((self = [super init])) { #if TARGET_OS_IPHONE if ([attributeName isEqualToString:(NSString *)kCTForegroundColorAttributeName]) { - _color = [[UIColor colorWithCGColor:object] retain]; + _color = [UIColor colorWithCGColor:object]; } else { - _color = object; + _color = (__bridge id)object; } #else - _color = [(id)object retain]; + _color = (__bridge id)object; #endif } return self; @@ -78,16 +78,11 @@ -(NSDictionary *)platformRepresentation { CFStringRef keys[] = { kCTForegroundColorAttributeName }; CFTypeRef values[] = { [self.color CGColor] }; - return [(NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) autorelease]; + return (__bridge_transfer NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); #else return [NSDictionary dictionaryWithObject:self.color forKey:NSForegroundColorAttributeName]; #endif } --(void)dealloc { - [_color release], _color = nil; - [super dealloc]; -} - @end \ No newline at end of file diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASGlyphInfo.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASGlyphInfo.m index 5a982f5..46c3766 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASGlyphInfo.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASGlyphInfo.m @@ -75,15 +75,10 @@ -(id)initWithGlyph:(NSGlyphInfo *)glyph baseString:(NSString *)baseString { #endif --(void)dealloc { - [_baseString release], _baseString = nil; - [super dealloc]; -} - #if TARGET_OS_IPHONE -(NSDictionary *)platformRepresentation { - CTGlyphInfoRef glyphinfo = CTGlyphInfoCreateWithCharacterIdentifier(self.characterIdentifier, self.characterCollection, (CFStringRef)self.baseString); + CTGlyphInfoRef glyphinfo = CTGlyphInfoCreateWithCharacterIdentifier(self.characterIdentifier, self.characterCollection, (__bridge CFStringRef)self.baseString); CFStringRef keys[] = { kCTGlyphInfoAttributeName }; CFTypeRef values[] = { glyphinfo }; @@ -91,7 +86,7 @@ -(NSDictionary *)platformRepresentation { CFDictionaryRef dict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFRelease(glyphinfo); - return [(NSDictionary *)dict autorelease]; + return (__bridge_transfer NSDictionary *)dict; } #else @@ -106,9 +101,9 @@ -(NSDictionary *)platformRepresentation { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return [(id)object isEqualToString:(NSString *)kCTGlyphInfoAttributeName]; + return [(__bridge id)object isEqualToString:(NSString *)kCTGlyphInfoAttributeName]; #else - return [(id)object isEqualToString:NSGlyphInfoAttributeName]; + return [(__bridge id)object isEqualToString:NSGlyphInfoAttributeName]; #endif } @@ -117,7 +112,7 @@ -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range: return [self initWithGlyph:(CTGlyphInfoRef)object baseString:[string.string substringWithRange:range]]; #else - return [self initWithGlyph:object baseString:[string.string substringWithRange:range]]; + return [self initWithGlyph:(__bridge NSGlyphInfo *)object baseString:[string.string substringWithRange:range]]; #endif } diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASKern.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASKern.m index 4b9b37e..4ff6c74 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASKern.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASKern.m @@ -36,7 +36,7 @@ @implementation MNASKern -(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super init])) { - _kern = [[aDecoder decodeObjectForKey:@"kern"] retain]; + _kern = [aDecoder decodeObjectForKey:@"kern"]; } return self; @@ -50,15 +50,15 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return (([(id)object isEqualToString:(NSString *)kCTKernAttributeName]) || ([(id)object isEqualToString:NSKernAttributeName])); + return (([(__bridge id)object isEqualToString:(NSString *)kCTKernAttributeName]) || ([(__bridge id)object isEqualToString:NSKernAttributeName])); #else - return [(id)object isEqualToString:NSKernAttributeName]; + return [(__bridge id)object isEqualToString:NSKernAttributeName]; #endif } -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { if ((self = [super init])) { - _kern = [(NSNumber *)object retain]; + _kern = (__bridge NSNumber *)object; } return self; } @@ -77,10 +77,4 @@ -(NSDictionary *)platformRepresentation { #endif } --(void)dealloc { - [_kern release], _kern = nil; - [super dealloc]; -} - - @end diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASLigature.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASLigature.m index 69894af..f0c240e 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASLigature.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASLigature.m @@ -36,7 +36,7 @@ @implementation MNASLigature -(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super init])) { - _type = [[aDecoder decodeObjectForKey:@"type"] retain]; + _type = [aDecoder decodeObjectForKey:@"type"]; } return self; @@ -50,15 +50,15 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return (([(id)object isEqualToString:(NSString *)kCTLigatureAttributeName]) || ([(id)object isEqualToString:NSLigatureAttributeName])); + return (([(__bridge id)object isEqualToString:(NSString *)kCTLigatureAttributeName]) || ([(__bridge id)object isEqualToString:NSLigatureAttributeName])); #else - return [(id)object isEqualToString:NSLigatureAttributeName]; + return [(__bridge id)object isEqualToString:NSLigatureAttributeName]; #endif } -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { if ((self = [super init])) { - _type = [(NSNumber *)object retain]; + _type = (__bridge NSNumber *)object; } return self; } @@ -77,10 +77,4 @@ -(NSDictionary *)platformRepresentation { #endif } --(void)dealloc { - [_type release], _type = nil; - [super dealloc]; -} - - @end \ No newline at end of file diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASParagraphyStyle.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASParagraphyStyle.m index 2007f59..23607a2 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASParagraphyStyle.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASParagraphyStyle.m @@ -82,7 +82,6 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { } - -(NSDictionary *)platformRepresentation { #if TARGET_OS_IPHONE @@ -105,7 +104,6 @@ -(NSDictionary *)platformRepresentation { platRep.paragraphSpacingBefore = self.paragraphSpacingBefore; NSDictionary *platformDict = [NSDictionary dictionaryWithObject:platRep forKey:NSParagraphStyleAttributeName]; - [platRep release]; return platformDict; } @@ -116,7 +114,7 @@ -(NSDictionary *)platformRepresentation { for (MNASTextTab *textTab in self.tabStops) { cttexttab = [textTab platformRepresentation]; - CFArrayAppendValue((CFMutableArrayRef)tempTabStops, cttexttab); + CFArrayAppendValue((__bridge CFMutableArrayRef)tempTabStops, cttexttab); CFRelease(cttexttab); } @@ -146,7 +144,8 @@ -(NSDictionary *)platformRepresentation { CFDictionaryRef dict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFRelease(paragraphStyle); - return [(NSDictionary *)dict autorelease]; + return (__bridge_transfer NSDictionary *)dict; + #else NSMutableParagraphStyle *platRep = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; @@ -174,25 +173,19 @@ -(NSDictionary *)platformRepresentation { platRep.paragraphSpacingBefore = self.paragraphSpacingBefore; NSDictionary *platformDict = [NSDictionary dictionaryWithObject:platRep forKey:NSParagraphStyleAttributeName]; - [platRep release]; return platformDict; #endif } --(void)dealloc { - [_tabStops release], _tabStops = nil; - [super dealloc]; -} - #pragma mark - MNCIntermediateObject Protocl +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return (([(id)object isEqualToString:(NSString *)kCTParagraphStyleAttributeName]) || ([(id)object isEqualToString:NSParagraphStyleAttributeName])); + return (([(__bridge id)object isEqualToString:(NSString *)kCTParagraphStyleAttributeName]) || ([(__bridge id)object isEqualToString:NSParagraphStyleAttributeName])); #else - return [(id)object isEqualToString:NSParagraphStyleAttributeName]; + return [(__bridge id)object isEqualToString:NSParagraphStyleAttributeName]; #endif } @@ -230,14 +223,14 @@ -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range: _hyphenationFactor = 0.0; } else { - NSParagraphStyle *paragraphStyle = object; + NSParagraphStyle *paragraphStyle = (__bridge id)object; _alignment = paragraphStyle.alignment; _lineBreakMode = paragraphStyle.lineBreakMode; _hyphenationFactor = paragraphStyle.hyphenationFactor; _baseWritingDirection = paragraphStyle.baseWritingDirection; - _tabStops = [[NSArray array] retain]; + _tabStops = [NSArray array]; _firstLineHeadIndent = paragraphStyle.firstLineHeadIndent; _headIndent = paragraphStyle.headIndent; diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeColor.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeColor.m index d80a96c..116b4d5 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeColor.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeColor.m @@ -36,7 +36,7 @@ @implementation MNASStrokeColor -(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super init])) { - _color = [[aDecoder decodeObjectForKey:@"color"] retain]; + _color = [aDecoder decodeObjectForKey:@"color"]; } return self; @@ -50,9 +50,9 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return (([(id)object isEqualToString:(NSString *)kCTStrokeColorAttributeName]) || ([(id)object isEqualToString:NSStrokeColorAttributeName])); + return (([(__bridge id)object isEqualToString:(NSString *)kCTStrokeColorAttributeName]) || ([(__bridge id)object isEqualToString:NSStrokeColorAttributeName])); #else - return [(id)object isEqualToString:NSStrokeColorAttributeName]; + return [(__bridge id)object isEqualToString:NSStrokeColorAttributeName]; #endif } @@ -60,13 +60,13 @@ -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range: if ((self = [super init])) { #if TARGET_OS_IPHONE if ([attributeName isEqualToString:(NSString *)kCTStrokeColorAttributeName]) { - _color = [[UIColor colorWithCGColor:object] retain]; + _color = [UIColor colorWithCGColor:object]; } else { - _color = [(id)object retain]; + _color = (__bridge id)object; } #else - _color = [(id)object retain]; + _color = (__bridge id)object; #endif } return self; @@ -81,7 +81,7 @@ -(NSDictionary *)platformRepresentation { CFStringRef keys[] = { kCTStrokeColorAttributeName }; CFTypeRef values[] = { [self.color CGColor] }; - return [(NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) autorelease]; + return (__bridge NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } #else @@ -89,10 +89,4 @@ -(NSDictionary *)platformRepresentation { #endif } --(void)dealloc { - [_color release], _color = nil; - [super dealloc]; -} - - @end \ No newline at end of file diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeWidth.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeWidth.m index b75ed74..244730e 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeWidth.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASStrokeWidth.m @@ -36,7 +36,7 @@ @implementation MNASStrokeWidth -(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super init])) { - _width = [[aDecoder decodeObjectForKey:@"width"] retain]; + _width = [aDecoder decodeObjectForKey:@"width"]; } return self; @@ -50,15 +50,15 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return (([(id)object isEqualToString:(NSString *)kCTStrokeWidthAttributeName]) || ([(id)object isEqualToString:NSStrokeWidthAttributeName])); + return (([(__bridge id)object isEqualToString:(NSString *)kCTStrokeWidthAttributeName]) || ([(__bridge id)object isEqualToString:NSStrokeWidthAttributeName])); #else - return [(id)object isEqualToString:NSStrokeWidthAttributeName]; + return [(__bridge id)object isEqualToString:NSStrokeWidthAttributeName]; #endif } -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { if ((self = [super init])) { - _width = [(NSNumber *)object retain]; + _width = (__bridge NSNumber *)object; } return self; } @@ -77,10 +77,5 @@ -(NSDictionary *)platformRepresentation { #endif } --(void)dealloc { - [_width release], _width = nil; - [super dealloc]; -} - @end \ No newline at end of file diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASSuperScript.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASSuperScript.m index dca1273..e1d3f96 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASSuperScript.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASSuperScript.m @@ -36,7 +36,7 @@ @implementation MNASSuperScript -(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super init])) { - _textPosition = [[aDecoder decodeObjectForKey:@"textPosition"] retain]; + _textPosition = [aDecoder decodeObjectForKey:@"textPosition"]; } return self; @@ -50,15 +50,15 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return [(id)object isEqualToString:(NSString *)kCTSuperscriptAttributeName]; + return [(__bridge id)object isEqualToString:(NSString *)kCTSuperscriptAttributeName]; #else - return [(id)object isEqualToString:NSSuperscriptAttributeName]; + return [(__bridge id)object isEqualToString:NSSuperscriptAttributeName]; #endif } -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { if ((self = [super init])) { - _textPosition = [(NSNumber *)object retain]; + _textPosition = (__bridge NSNumber *)object; } return self; } @@ -71,10 +71,4 @@ -(NSDictionary *)platformRepresentation { #endif } --(void)dealloc { - [_textPosition release], _textPosition = nil; - [super dealloc]; -} - - @end \ No newline at end of file diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASTextTab.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASTextTab.m index faefa83..0c8d9ee 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASTextTab.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASTextTab.m @@ -54,14 +54,14 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { #if TARGET_OS_IPHONE +(id)textTabWithTabStop:(CTTextTabRef)tab { - return [[[self alloc] initWithTabStop:tab] autorelease]; + return [[self alloc] initWithTabStop:tab]; } -(id)initWithTabStop:(CTTextTabRef)tab { if ((self = [super init])) { _alignment = CTTextTabGetAlignment(tab); _location = CTTextTabGetLocation(tab); - _options = [((NSDictionary *)CTTextTabGetOptions(tab)) copy]; + _options = [((__bridge NSDictionary *)CTTextTabGetOptions(tab)) copy]; } return self; } @@ -69,7 +69,7 @@ -(id)initWithTabStop:(CTTextTabRef)tab { #else +(id)textTabWithTabStop:(NSTextTab *)tab { - return [[[self alloc] initWithTabStop:tab] autorelease]; + return [[self alloc] initWithTabStop:tab]; } -(id)initWithTabStop:(NSTextTab *)tab { @@ -83,21 +83,16 @@ -(id)initWithTabStop:(NSTextTab *)tab { #endif --(void)dealloc { - [_options release], _options = nil; - [super dealloc]; -} - #if TARGET_OS_IPHONE -(CTTextTabRef)platformRepresentation { - return CTTextTabCreate(self.alignment, self.location, (CFDictionaryRef)self.options); + return CTTextTabCreate(self.alignment, self.location, (__bridge CFDictionaryRef)self.options); } #else -(NSTextTab *)platformRepresentation { - return [[[NSTextTab alloc] initWithTextAlignment:self.alignment location:self.location options:self.options] autorelease]; + return [[NSTextTab alloc] initWithTextAlignment:self.alignment location:self.location options:self.options]; } #endif diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineColor.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineColor.m index a8fe9a6..17bd414 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineColor.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineColor.m @@ -36,7 +36,7 @@ @implementation MNASUnderlineColor -(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super init])) { - _color = [[aDecoder decodeObjectForKey:@"color"] retain]; + _color = [aDecoder decodeObjectForKey:@"color"]; } return self; @@ -50,18 +50,18 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return [(id)object isEqualToString:(NSString *)kCTUnderlineColorAttributeName]; + return [(__bridge id)object isEqualToString:(NSString *)kCTUnderlineColorAttributeName]; #else - return [(id)object isEqualToString:NSUnderlineColorAttributeName]; + return [(__bridge id)object isEqualToString:NSUnderlineColorAttributeName]; #endif } -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { if ((self = [super init])) { #if TARGET_OS_IPHONE - _color = [[UIColor colorWithCGColor:object] retain]; + _color = [UIColor colorWithCGColor:object]; #else - _color = [(id)object retain]; + _color = (__bridge id)object; #endif } @@ -73,16 +73,10 @@ -(NSDictionary *)platformRepresentation { CFStringRef keys[] = { kCTUnderlineColorAttributeName }; CFTypeRef values[] = { [self.color CGColor] }; - return [(NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) autorelease]; + return (__bridge_transfer NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); #else return [NSDictionary dictionaryWithObject:self.color forKey:NSUnderlineColorAttributeName]; #endif } --(void)dealloc { - [_color release], _color = nil; - [super dealloc]; -} - - @end \ No newline at end of file diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineStyle.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineStyle.m index c36aefb..7a70a68 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineStyle.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASUnderlineStyle.m @@ -36,7 +36,7 @@ @implementation MNASUnderlineStyle -(id)initWithCoder:(NSCoder *)aDecoder { if ((self = [super init])) { - _styleMask = [[aDecoder decodeObjectForKey:@"styleMask"] retain]; + _styleMask = [aDecoder decodeObjectForKey:@"styleMask"]; } return self; @@ -50,15 +50,15 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return (([(id)object isEqualToString:(NSString *)kCTUnderlineStyleAttributeName]) || ([(id)object isEqualToString:NSUnderlineStyleAttributeName])); + return (([(__bridge id)object isEqualToString:(NSString *)kCTUnderlineStyleAttributeName]) || ([(__bridge id)object isEqualToString:NSUnderlineStyleAttributeName])); #else - return [(id)object isEqualToString:NSUnderlineStyleAttributeName]; + return [(__bridge id)object isEqualToString:NSUnderlineStyleAttributeName]; #endif } -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range:(NSRange)range forAttributedString:(NSAttributedString *)string { if ((self = [super init])) { - _styleMask = [(NSNumber *)object retain]; + _styleMask = (__bridge NSNumber *)object; } return self; } @@ -71,10 +71,5 @@ -(NSDictionary *)platformRepresentation { #endif } --(void)dealloc { - [_styleMask release], _styleMask = nil; - [super dealloc]; -} - @end \ No newline at end of file diff --git a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASVerticalForms.m b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASVerticalForms.m index c870d53..521a3d2 100644 --- a/MNCoder/IntermediateObjects/NSAttributedStrings/MNASVerticalForms.m +++ b/MNCoder/IntermediateObjects/NSAttributedStrings/MNASVerticalForms.m @@ -50,9 +50,9 @@ -(void)encodeWithCoder:(NSCoder *)aCoder { +(BOOL)isSubstituteForObject:(void *)object { #if TARGET_OS_IPHONE - return (([(id)object isEqualToString:(NSString *)kCTVerticalFormsAttributeName]) || ([(id)object isEqualToString:NSVerticalGlyphFormAttributeName])); + return (([(__bridge id)object isEqualToString:(NSString *)kCTVerticalFormsAttributeName]) || ([(__bridge id)object isEqualToString:NSVerticalGlyphFormAttributeName])); #else - return [(id)object isEqualToString:NSVerticalGlyphFormAttributeName]; + return [(__bridge id)object isEqualToString:NSVerticalGlyphFormAttributeName]; #endif } @@ -66,7 +66,7 @@ -(id)initWithAttributeName:(NSString *)attributeName value:(void *)object range: _enabled = NO; } } else { - _enabled = [(NSNumber *)object boolValue]; + _enabled = [(__bridge NSNumber *)object boolValue]; } #else @@ -93,7 +93,7 @@ -(NSDictionary *)platformRepresentation { CFStringRef keys[] = { kCTVerticalFormsAttributeName }; CFTypeRef values[] = { verticalFormsEnabled }; - return [(NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) autorelease]; + return (__bridge NSDictionary *)CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys , (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } #else diff --git a/MNCoder/MNArchiver.m b/MNCoder/MNArchiver.m index 7b8b79b..6eaf846 100644 --- a/MNCoder/MNArchiver.m +++ b/MNCoder/MNArchiver.m @@ -55,8 +55,6 @@ -(id)initForWritingWithMutableData:(NSMutableData *)data { -(void)dealloc { __archiver.delegate = nil; - [__archiver release], __archiver = nil; - [super dealloc]; } #pragma mark - Override Accessors @@ -84,7 +82,7 @@ -(void)encodeRootObject:(id)object { +(NSData *)archivedDataWithRootObject:(id)object { NSMutableData *resultData = [NSMutableData dataWithCapacity:0]; - MNArchiver *archiver = [[[MNArchiver alloc] initForWritingWithMutableData:resultData] autorelease]; + MNArchiver *archiver = [[MNArchiver alloc] initForWritingWithMutableData:resultData]; archiver.outputFormat = NSPropertyListBinaryFormat_v1_0; [archiver registerSubstituteClass:[MNFont class]]; [archiver registerSubstituteClass:[MNColor class]]; @@ -115,8 +113,8 @@ -(id)archiver:(NSKeyedArchiver *)archiver willEncodeObject:(id)object { for (Class cls in __subsituteClasses) { - if ([cls isSubstituteForObject:object]) { - return [[[cls alloc] initWithSubsituteObject:object] autorelease]; + if ([cls isSubstituteForObject:(__bridge void*)object]) { + return [[cls alloc] initWithSubsituteObject:(__bridge void*)object]; } } diff --git a/MNCoder/MNCoder.m b/MNCoder/MNCoder.m index 848597b..3e53840 100644 --- a/MNCoder/MNCoder.m +++ b/MNCoder/MNCoder.m @@ -38,16 +38,11 @@ @implementation MNCoder -(id)init { if ((self = [super init])) { - __subsituteClasses = [[NSMutableSet setWithCapacity:0] retain]; + __subsituteClasses = [NSMutableSet setWithCapacity:0]; } return self; } --(void)dealloc { - [__subsituteClasses release], __subsituteClasses = nil; - [super dealloc]; -} - #pragma mark - Instance Methods -(void)registerSubstituteClass:(Class)cls { if ([cls conformsToProtocol:@protocol(MNCIntermediateObjectProtocol)]) diff --git a/MNCoder/MNUnarchiver.m b/MNCoder/MNUnarchiver.m index 9c15bfe..69b713d 100644 --- a/MNCoder/MNUnarchiver.m +++ b/MNCoder/MNUnarchiver.m @@ -66,37 +66,29 @@ -(id)initForReadingWithData:(NSData *)data { return self; } --(void)dealloc { - [_decodedRootObject release], _decodedRootObject = nil; - [__unarchiver release], __unarchiver = nil; - [super dealloc]; -} #pragma mark - Instance Methods -(id)decodedRootObject { if (!_decodedRootObject) { - _decodedRootObject = [[__unarchiver decodeObjectForKey:MNCoderRootObjectName] retain]; + _decodedRootObject = [__unarchiver decodeObjectForKey:MNCoderRootObjectName]; // after finishing the decode, the unarchiver can't be used anymore, // lets proactively release it to reclaim memory. [__unarchiver finishDecoding]; - [__unarchiver release], __unarchiver = nil; } - id test = [[_decodedRootObject retain] autorelease]; - - return test; + return _decodedRootObject; } #pragma mark - Static Methods +(id)unarchiveObjectWithData:(NSData *)data { - MNUnarchiver *unarchiver = [[[MNUnarchiver alloc] initForReadingWithData:data] autorelease]; + MNUnarchiver *unarchiver = [[MNUnarchiver alloc] initForReadingWithData:data]; [unarchiver registerSubstituteClass:[MNFont class]]; [unarchiver registerSubstituteClass:[MNColor class]]; [unarchiver registerSubstituteClass:[MNAttributedString class]]; - return [[[unarchiver decodedRootObject] retain] autorelease]; + return [unarchiver decodedRootObject]; } +(id)unarchiveObjectWithFile:(NSString *)path { @@ -107,9 +99,7 @@ +(id)unarchiveObjectWithFile:(NSString *)path { NSData *data = [NSData dataWithContentsOfFile:path]; - id unarchivedObj = [MNUnarchiver unarchiveObjectWithData:data]; - - return [[unarchivedObj retain] autorelease]; + return [MNUnarchiver unarchiveObjectWithData:data]; } #pragma mark - NSKeyedUnarchiver Delegate Methods @@ -127,14 +117,12 @@ -(Class)unarchiver:(NSKeyedUnarchiver *)unarchiver cannotDecodeObjectOfClassName return nil; } --(id)unarchiver:(NSKeyedUnarchiver *)unarchiver didDecodeObject:(id)object NS_RETURNS_RETAINED { +-(id)unarchiver:(NSKeyedUnarchiver *)unarchiver didDecodeObject:(id)object { for (Class cls in __subsituteClasses) { if ([object isKindOfClass:cls]) { - id platformRepresentation = [[object platformRepresentation] retain]; - [object release]; - + // NSKeyedUnarchiver does not retain the replacement object thus a temp workaround with analyzer warning // is not to autorelease it. // @@ -143,7 +131,7 @@ -(id)unarchiver:(NSKeyedUnarchiver *)unarchiver didDecodeObject:(id)object NS_RE // inference that this is not retained upon the return. // // Will be filing a radar for this issue. (http://openradar.appspot.com/radar?id=1517414) - return platformRepresentation; + return [object platformRepresentation]; } } diff --git a/Mac/Mac.xcodeproj/project.pbxproj b/Mac/Mac.xcodeproj/project.pbxproj index 0a6bbd1..c355429 100644 --- a/Mac/Mac.xcodeproj/project.pbxproj +++ b/Mac/Mac.xcodeproj/project.pbxproj @@ -398,6 +398,7 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; GCC_OPTIMIZATION_LEVEL = s; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Mac/Mac-Prefix.pch"; @@ -412,6 +413,7 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Mac/Mac-Prefix.pch"; INFOPLIST_FILE = "Mac/Mac-Info.plist"; diff --git a/Mac/Mac/MNAppDelegate.m b/Mac/Mac/MNAppDelegate.m index 00724ed..cb06bf8 100644 --- a/Mac/Mac/MNAppDelegate.m +++ b/Mac/Mac/MNAppDelegate.m @@ -43,11 +43,6 @@ @implementation MNAppDelegate @synthesize textView; @synthesize unarchiveTextView; -- (void)dealloc -{ - [super dealloc]; -} - - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code here to initialize your application diff --git a/iOS/iOS.xcodeproj/project.pbxproj b/iOS/iOS.xcodeproj/project.pbxproj index dc6316c..bed81d9 100644 --- a/iOS/iOS.xcodeproj/project.pbxproj +++ b/iOS/iOS.xcodeproj/project.pbxproj @@ -29,7 +29,7 @@ 3F8561E114CB705700B7FE8D /* MNASKern.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F8561E014CB705700B7FE8D /* MNASKern.m */; }; 3F8561EC14CB722300B7FE8D /* MNASLigature.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F8561E914CB722300B7FE8D /* MNASLigature.m */; }; 3F8561ED14CB722300B7FE8D /* MNASStrokeWidth.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F8561EB14CB722300B7FE8D /* MNASStrokeWidth.m */; }; - 3F95E55914C751E70096CE62 /* EGOTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F95E54F14C751E70096CE62 /* EGOTextView.m */; }; + 3F95E55914C751E70096CE62 /* EGOTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F95E54F14C751E70096CE62 /* EGOTextView.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 3F95E55A14C751E70096CE62 /* drag-dot@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F95E55114C751E70096CE62 /* drag-dot@2x.png */; }; 3F95E55B14C751E70096CE62 /* loupe-hi@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F95E55214C751E70096CE62 /* loupe-hi@2x.png */; }; 3F95E55C14C751E70096CE62 /* loupe-lo@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F95E55314C751E70096CE62 /* loupe-lo@2x.png */; }; @@ -405,6 +405,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -429,6 +430,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -446,6 +448,7 @@ 3F18E44414B7D74600303392 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "iOS/iOS-Prefix.pch"; INFOPLIST_FILE = "iOS/iOS-Info.plist"; @@ -457,6 +460,7 @@ 3F18E44514B7D74600303392 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "iOS/iOS-Prefix.pch"; INFOPLIST_FILE = "iOS/iOS-Info.plist"; diff --git a/iOS/iOS/MNAppDelegate.m b/iOS/iOS/MNAppDelegate.m index c2eea07..669e1f4 100644 --- a/iOS/iOS/MNAppDelegate.m +++ b/iOS/iOS/MNAppDelegate.m @@ -36,23 +36,15 @@ @implementation MNAppDelegate @synthesize window = _window; @synthesize viewController = _viewController; -- (void)dealloc -{ - [_window release]; - [_viewController release]; - [super dealloc]; -} - - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. - self.viewController = [[[MNViewController alloc] initWithNibName:@"MNViewController" bundle:nil] autorelease]; + self.viewController = [[MNViewController alloc] initWithNibName:@"MNViewController" bundle:nil]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.viewController]; self.window.rootViewController = nav; - [nav release]; - + [self.window makeKeyAndVisible]; return YES; } diff --git a/iOS/iOS/MNViewController.m b/iOS/iOS/MNViewController.m index 10a9e36..7076af5 100644 --- a/iOS/iOS/MNViewController.m +++ b/iOS/iOS/MNViewController.m @@ -98,13 +98,6 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } -- (void)dealloc { - [textView release]; - [segmentedButtons release]; - [actionButton release]; - [super dealloc]; -} - - (IBAction)actionButtonTapped:(id)sender { if (self.segmentedButtons.selectedSegmentIndex == 0) { // do archive