TouchCode / TouchJSON

A humane JSON Objective-C un-framework. (TouchJSON has been deprecated - see README)
http://touchcode.com/
Other
800 stars 169 forks source link

Failing to run on IOS 3.1.2 #17

Closed andypondy closed 12 years ago

andypondy commented 12 years ago

Hi,

Am using [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error]];

The code and decode run fine on iOS 4. (no issues there)

But on iOS 3.1.2, I get the following error

dyld: lazy symbol binding failed: Symbol not found: _dispatch_once Referenced from: /var/mobile/Applications/C2DD12ED-9497-4CF8-955D-0510FA76DCB5/iCric2.app/iCric2 Expected in: /usr/lib/libSystem.B.dylib

I know I am supposed to weak link something or change a setting somewhere. Just cannot figure out what.

Base SDK 4.2 iOS deployment target - iOS 3.1.2 Mac OS X deployment target - Mac OS 10.5 weak link to MessageUI Your help is appreciated.

schwa commented 12 years ago

Sorry but I'm only supporting iOS 4 and higher now.

To support iOS 3.2 you can find the initialise method in CJSONScanner.m and change it from:

+ (void)initialize
    {
    static dispatch_once_t sOnceToken = 0;
    dispatch_once(&sOnceToken, ^{
        kNSYES = [NSNumber numberWithBool:YES];
        kNSNO = [NSNumber numberWithBool:NO];
        });
    }

to:

+ (void)initialize
    {
    kNSYES = [NSNumber numberWithBool:YES];
    kNSNO = [NSNumber numberWithBool:NO];
    }

It's not quite as safe but should be good enough.

schwa commented 12 years ago

Actually after doing a bit of research it looks like +initialize is thread safe and dispatch_once is unneeded.

I've committed changes that remove this function call and clean up the +initialize class methods somewhat.