Permalink
Browse files

Check that NSCache is supported on current OS. If not, fall back to n…

…ot do caching. This lets us support iOS 3.x.
  • Loading branch information...
1 parent afe369c commit d0903fc27b4012bf9333d6e8ca5379602aca9e62 @HagerHu HagerHu committed with stig Jun 4, 2011
Showing with 11 additions and 2 deletions.
  1. +11 −2 Classes/SBJsonStreamWriter.m
View
13 Classes/SBJsonStreamWriter.m
@@ -34,7 +34,7 @@
#import "SBJsonStreamWriterState.h"
static NSDecimalNumber *kNotANumber;
-static NSCache *kStaticStringCache;
+static id kStaticStringCache;
@implementation SBJsonStreamWriter
@@ -48,7 +48,16 @@ @implementation SBJsonStreamWriter
+ (void)initialize {
kNotANumber = [NSDecimalNumber notANumber];
- kStaticStringCache = [[NSCache alloc] init];
+
+ Class cacheClass = NSClassFromString(@"NSCache");
+ if (cacheClass) {
+ NSLog(@"%s NSCache supported", __FUNCTION__);
+ kStaticStringCache = [[cacheClass alloc] init];
+ }else {
+ NSLog(@"%s NSCache not supported", __FUNCTION__);
+ }
+
+
}
#pragma mark Housekeeping

0 comments on commit d0903fc

Please sign in to comment.