diff options
Diffstat (limited to 'Source/SPStringAdditions.h')
-rw-r--r-- | Source/SPStringAdditions.h | 16 |
1 files changed, 16 insertions, 0 deletions
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; |