aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPStringAdditions.h
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-03-31 18:24:37 +0000
committerstuconnolly <stuart02@gmail.com>2010-03-31 18:24:37 +0000
commit786a51fb9539858aa8974d9fd93e9410867ee08d (patch)
tree5c27f959e01e3b4310009d93f29d5f9fcdb32eea /Source/SPStringAdditions.h
parentef9f2de4c69410664f5c75db6b512138c7df72aa (diff)
downloadsequelpro-786a51fb9539858aa8974d9fd93e9410867ee08d.tar.gz
sequelpro-786a51fb9539858aa8974d9fd93e9410867ee08d.tar.bz2
sequelpro-786a51fb9539858aa8974d9fd93e9410867ee08d.zip
More tidy up. Constants and functions.
Diffstat (limited to 'Source/SPStringAdditions.h')
-rw-r--r--Source/SPStringAdditions.h16
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;