From 80a3efae23f99d1099c808891652b654d5041cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E4=BD=99=E7=8C=9B?= Date: Thu, 13 Feb 2014 14:43:24 +0800 Subject: [PATCH] type convert waring resolve (int -> NSInteger) --- RTLabelProject/Classes/RTLabel.h | 8 ++--- RTLabelProject/Classes/RTLabel.m | 56 ++++++++++++++++---------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/RTLabelProject/Classes/RTLabel.h b/RTLabelProject/Classes/RTLabel.h index 3a5443b..aef93a1 100755 --- a/RTLabelProject/Classes/RTLabel.h +++ b/RTLabelProject/Classes/RTLabel.h @@ -64,12 +64,12 @@ typedef enum @property (nonatomic, copy) NSString *text; @property (nonatomic, copy) NSString *tagLabel; @property (nonatomic) NSMutableDictionary *attributes; -@property (nonatomic, assign) int position; +@property (nonatomic, assign) NSInteger position; - (id)initWithString:(NSString*)aText tag:(NSString*)aTagLabel attributes:(NSMutableDictionary*)theAttributes; + (id)componentWithString:(NSString*)aText tag:(NSString*)aTagLabel attributes:(NSMutableDictionary*)theAttributes; -- (id)initWithTag:(NSString*)aTagLabel position:(int)_position attributes:(NSMutableDictionary*)_attributes; -+ (id)componentWithTag:(NSString*)aTagLabel position:(int)aPosition attributes:(NSMutableDictionary*)theAttributes; +- (id)initWithTag:(NSString*)aTagLabel position:(NSInteger)_position attributes:(NSMutableDictionary*)_attributes; ++ (id)componentWithTag:(NSString*)aTagLabel position:(NSInteger)aPosition attributes:(NSMutableDictionary*)theAttributes; @end @@ -85,7 +85,7 @@ typedef enum @property (nonatomic, strong) UIFont *font; @property (nonatomic, strong) NSDictionary *linkAttributes; @property (nonatomic, strong) NSDictionary *selectedLinkAttributes; -@property (nonatomic, unsafe_unretained) id delegate; +@property (nonatomic, weak) id delegate; @property (nonatomic, copy) NSString *paragraphReplacement; @property (nonatomic, strong) NSMutableArray *textComponents, *highlightedTextComponents; @property (nonatomic, assign) RTTextAlignment textAlignment; diff --git a/RTLabelProject/Classes/RTLabel.m b/RTLabelProject/Classes/RTLabel.m index 4cf8624..c98b73e 100755 --- a/RTLabelProject/Classes/RTLabel.m +++ b/RTLabelProject/Classes/RTLabel.m @@ -63,7 +63,7 @@ + (id)componentWithString:(NSString*)aText tag:(NSString*)aTagLabel attributes:( return [[self alloc] initWithString:aText tag:aTagLabel attributes:theAttributes]; } -- (id)initWithTag:(NSString*)aTagLabel position:(int)aPosition attributes:(NSMutableDictionary*)theAttributes +- (id)initWithTag:(NSString*)aTagLabel position:(NSInteger)aPosition attributes:(NSMutableDictionary*)theAttributes { self = [super init]; if (self) { @@ -74,7 +74,7 @@ - (id)initWithTag:(NSString*)aTagLabel position:(int)aPosition attributes:(NSMut return self; } -+(id)componentWithTag:(NSString*)aTagLabel position:(int)aPosition attributes:(NSMutableDictionary*)theAttributes ++(id)componentWithTag:(NSString*)aTagLabel position:(NSInteger)aPosition attributes:(NSMutableDictionary*)theAttributes { return [[self alloc] initWithTag:aTagLabel position:aPosition attributes:theAttributes]; } @@ -83,7 +83,7 @@ - (NSString*)description { NSMutableString *desc = [NSMutableString string]; [desc appendFormat:@"text: %@", self.text]; - [desc appendFormat:@", position: %i", self.position]; + [desc appendFormat:@", position: %ld",(long) self.position]; if (self.tagLabel) [desc appendFormat:@", tag: %@", self.tagLabel]; if (self.attributes) [desc appendFormat:@", attributes: %@", self.attributes]; return desc; @@ -114,15 +114,15 @@ - (void)render; #pragma mark - #pragma mark styling -- (void)applyItalicStyleToText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length; -- (void)applyBoldStyleToText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length; -- (void)applyBoldItalicStyleToText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length; -- (void)applyColor:(NSString*)value toText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length; -- (void)applySingleUnderlineText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length; -- (void)applyDoubleUnderlineText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length; -- (void)applyUnderlineColor:(NSString*)value toText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length; -- (void)applyFontAttributes:(NSDictionary*)attributes toText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length; -- (void)applyParagraphStyleToText:(CFMutableAttributedStringRef)text attributes:(NSMutableDictionary*)attributes atPosition:(int)position withLength:(int)length; +- (void)applyItalicStyleToText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length; +- (void)applyBoldStyleToText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length; +- (void)applyBoldItalicStyleToText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length; +- (void)applyColor:(NSString*)value toText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length; +- (void)applySingleUnderlineText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length; +- (void)applyDoubleUnderlineText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length; +- (void)applyUnderlineColor:(NSString*)value toText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length; +- (void)applyFontAttributes:(NSDictionary*)attributes toText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length; +- (void)applyParagraphStyleToText:(CFMutableAttributedStringRef)text attributes:(NSMutableDictionary*)attributes atPosition:(NSInteger)position withLength:(NSInteger)length; @end @implementation RTLabel @@ -232,7 +232,7 @@ - (void)render for (RTLabelComponent *component in textComponents) { - int index = [textComponents indexOfObject:component]; + NSInteger index = [textComponents indexOfObject:component]; component.componentIndex = index; if ([component.tagLabel caseInsensitiveCompare:@"i"] == NSOrderedSame) @@ -393,7 +393,7 @@ - (void)render #pragma mark - #pragma mark styling -- (void)applyParagraphStyleToText:(CFMutableAttributedStringRef)text attributes:(NSMutableDictionary*)attributes atPosition:(int)position withLength:(int)length +- (void)applyParagraphStyleToText:(CFMutableAttributedStringRef)text attributes:(NSMutableDictionary*)attributes atPosition:(NSInteger)position withLength:(NSInteger)length { CFMutableDictionaryRef styleDict = ( CFDictionaryCreateMutable( (0), 0, (0), (0) ) ); @@ -494,7 +494,7 @@ - (void)applyParagraphStyleToText:(CFMutableAttributedStringRef)text attributes: CFRelease(styleDict); } -- (void)applyCenterStyleToText:(CFMutableAttributedStringRef)text attributes:(NSMutableDictionary*)attributes atPosition:(int)position withLength:(int)length +- (void)applyCenterStyleToText:(CFMutableAttributedStringRef)text attributes:(NSMutableDictionary*)attributes atPosition:(NSInteger)position withLength:(NSInteger)length { CFMutableDictionaryRef styleDict = ( CFDictionaryCreateMutable( (0), 0, (0), (0) ) ); @@ -539,17 +539,17 @@ - (void)applyCenterStyleToText:(CFMutableAttributedStringRef)text attributes:(NS CFRelease(styleDict); } -- (void)applySingleUnderlineText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length +- (void)applySingleUnderlineText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length { CFAttributedStringSetAttribute(text, CFRangeMake(position, length), kCTUnderlineStyleAttributeName, (__bridge CFNumberRef)[NSNumber numberWithInt:kCTUnderlineStyleSingle]); } -- (void)applyDoubleUnderlineText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length +- (void)applyDoubleUnderlineText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length { CFAttributedStringSetAttribute(text, CFRangeMake(position, length), kCTUnderlineStyleAttributeName, (__bridge CFNumberRef)[NSNumber numberWithInt:kCTUnderlineStyleDouble]); } -- (void)applyItalicStyleToText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length +- (void)applyItalicStyleToText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length { CFTypeRef actualFontRef = CFAttributedStringGetAttribute(text, position, kCTFontAttributeName, NULL); CTFontRef italicFontRef = CTFontCreateCopyWithSymbolicTraits(actualFontRef, 0.0, NULL, kCTFontItalicTrait, kCTFontItalicTrait); @@ -562,7 +562,7 @@ - (void)applyItalicStyleToText:(CFMutableAttributedStringRef)text atPosition:(in CFRelease(italicFontRef); } -- (void)applyFontAttributes:(NSDictionary*)attributes toText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length +- (void)applyFontAttributes:(NSDictionary*)attributes toText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length { for (NSString *key in attributes) { @@ -631,7 +631,7 @@ - (void)applyFontAttributes:(NSDictionary*)attributes toText:(CFMutableAttribute } } -- (void)applyBoldStyleToText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length +- (void)applyBoldStyleToText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length { CFTypeRef actualFontRef = CFAttributedStringGetAttribute(text, position, kCTFontAttributeName, NULL); CTFontRef boldFontRef = CTFontCreateCopyWithSymbolicTraits(actualFontRef, 0.0, NULL, kCTFontBoldTrait, kCTFontBoldTrait); @@ -644,7 +644,7 @@ - (void)applyBoldStyleToText:(CFMutableAttributedStringRef)text atPosition:(int) CFRelease(boldFontRef); } -- (void)applyBoldItalicStyleToText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length +- (void)applyBoldItalicStyleToText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length { CFTypeRef actualFontRef = CFAttributedStringGetAttribute(text, position, kCTFontAttributeName, NULL); CTFontRef boldItalicFontRef = CTFontCreateCopyWithSymbolicTraits(actualFontRef, 0.0, NULL, kCTFontBoldTrait | kCTFontItalicTrait , kCTFontBoldTrait | kCTFontItalicTrait); @@ -661,7 +661,7 @@ - (void)applyBoldItalicStyleToText:(CFMutableAttributedStringRef)text atPosition } -- (void)applyColor:(NSString*)value toText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length +- (void)applyColor:(NSString*)value toText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length { if ([value rangeOfString:@"#"].location==0) @@ -686,7 +686,7 @@ - (void)applyColor:(NSString*)value toText:(CFMutableAttributedStringRef)text at } } -- (void)applyUnderlineColor:(NSString*)value toText:(CFMutableAttributedStringRef)text atPosition:(int)position withLength:(int)length +- (void)applyUnderlineColor:(NSString*)value toText:(CFMutableAttributedStringRef)text atPosition:(NSInteger)position withLength:(NSInteger)length { value = [value stringByReplacingOccurrencesOfString:@"'" withString:@""]; @@ -865,7 +865,7 @@ + (RTLabelExtractedComponent*)extractTextStyleFromText:(NSString*)data paragraph NSMutableArray *components = [NSMutableArray array]; - int last_position = 0; + NSInteger last_position = 0; scanner = [NSScanner scannerWithString:data]; while (![scanner isAtEnd]) { @@ -873,7 +873,7 @@ + (RTLabelExtractedComponent*)extractTextStyleFromText:(NSString*)data paragraph [scanner scanUpToString:@">" intoString:&text]; NSString *delimiter = [NSString stringWithFormat:@"%@>", text]; - int position = [data rangeOfString:delimiter].location; + NSInteger position = [data rangeOfString:delimiter].location; if (position!=NSNotFound) { if ([delimiter rangeOfString:@"=0; i--) + for (NSInteger i=[components count]-1; i>=0; i--) { RTLabelComponent *component = [components objectAtIndex:i]; if (component.text==nil && [component.tagLabel isEqualToString:tag]) @@ -956,7 +956,7 @@ - (void)parse:(NSString *)data valid_tags:(NSArray *)valid_tags scanner = [NSScanner scannerWithString:data]; NSMutableDictionary *lastAttributes = nil; - int last_position = 0; + NSInteger last_position = 0; while([scanner isAtEnd] == NO) { //find start of tag @@ -995,7 +995,7 @@ - (void)parse:(NSString *)data valid_tags:(NSArray *)valid_tags if([valid_tags containsObject:tag] == NO) { NSString *delimiter = [NSString stringWithFormat:@"%@>", text]; - int position = [data rangeOfString:delimiter].location; + NSInteger position = [data rangeOfString:delimiter].location; BOOL isEnd = [delimiter rangeOfString:@"