Skip to content

Commit

Permalink
Check that NSCache is supported on current OS. If not, fall back to n…
Browse files Browse the repository at this point in the history
…ot do caching. This lets us support iOS 3.x.
  • Loading branch information
HagerHu authored and stig committed Jun 5, 2011
1 parent afe369c commit d0903fc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Classes/SBJsonStreamWriter.m
Expand Up @@ -34,7 +34,7 @@
#import "SBJsonStreamWriterState.h"

static NSDecimalNumber *kNotANumber;
static NSCache *kStaticStringCache;
static id kStaticStringCache;


@implementation SBJsonStreamWriter
Expand All @@ -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
Expand Down

0 comments on commit d0903fc

Please sign in to comment.