From 786a51fb9539858aa8974d9fd93e9410867ee08d Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Wed, 31 Mar 2010 18:24:37 +0000 Subject: More tidy up. Constants and functions. --- Source/SPStringAdditions.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Source/SPStringAdditions.h') diff --git a/Source/SPStringAdditions.h b/Source/SPStringAdditions.h index b67baa54..3f7c9066 100644 --- a/Source/SPStringAdditions.h +++ b/Source/SPStringAdditions.h @@ -38,6 +38,22 @@ static inline const char* NSStringUTF8String(NSString* self) { return to_return; } +static inline void NSMutableAttributedStringAddAttributeValueRange (NSMutableAttributedString* self, NSString* aStr, id aValue, NSRange aRange) { + typedef void (*SPMutableAttributedStringAddAttributeValueRangeMethodPtr)(NSMutableAttributedString*, SEL, NSString*, id, NSRange); + static SPMutableAttributedStringAddAttributeValueRangeMethodPtr SPMutableAttributedStringAddAttributeValueRange; + if (!SPMutableAttributedStringAddAttributeValueRange) SPMutableAttributedStringAddAttributeValueRange = (SPMutableAttributedStringAddAttributeValueRangeMethodPtr)[self methodForSelector:@selector(addAttribute:value:range:)]; + SPMutableAttributedStringAddAttributeValueRange(self, @selector(addAttribute:value:range:), aStr, aValue, aRange); + return; +} + +static inline id NSMutableAttributedStringAttributeAtIndex (NSMutableAttributedString* self, NSString* aStr, NSUInteger index, NSRangePointer range) { + typedef id (*SPMutableAttributedStringAttributeAtIndexMethodPtr)(NSMutableAttributedString*, SEL, NSString*, NSUInteger, NSRangePointer); + static SPMutableAttributedStringAttributeAtIndexMethodPtr SPMutableAttributedStringAttributeAtIndex; + if (!SPMutableAttributedStringAttributeAtIndex) SPMutableAttributedStringAttributeAtIndex = (SPMutableAttributedStringAttributeAtIndexMethodPtr)[self methodForSelector:@selector(attribute:atIndex:effectiveRange:)]; + id r = SPMutableAttributedStringAttributeAtIndex(self, @selector(attribute:atIndex:effectiveRange:), aStr, index, range); + return r; +} + @interface NSString (SPStringAdditions) + (NSString *)stringForByteSize:(long long)byteSize; -- cgit v1.2.3