iPhone应用程式的JSON错误 [英] JSON error on iPhone app

查看:205
本文介绍了iPhone应用程式的JSON错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在我的模拟器上运行应用程序时,我得到错误。
我在我的应用程序中复制了JSON(JSON框架)项目,但我的模拟器崩溃时,它编译下面的行,(我使用的是iOS 4.2)

i am getting error when i try to run an app on my simulator. I have copied the JSON(JSON Framework) project in my app but my simulator crashes when it compiles the below lines,(I am using iOS 4.2)

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *jsonString = [NSString stringWithString:@"{\"foo\": \"bar\"}"];
    NSDictionary *dictionary = [jsonString JSONValue];
    NSLog(@"Dictionary value for \"foo\" is \"%@\"", [dictionary objectForKey:@"foo"]);
}

错误:

2011-03-02 13:33:37.304 test[10918:207] -[NSCFString JSONValue]: unrecognized selector sent to instance 0x3034
2011-03-02 13:33:37.308 test[10918:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString JSONValue]: unrecognized selector sent to instance 0x3034'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00da7be9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00efc5c2 objc_exception_throw + 47
    2   CoreFoundation                      0x00da96fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x00d19366 ___forwarding___ + 966
    4   CoreFoundation                      0x00d18f22 _CF_forwarding_prep_0 + 50
    5   test                                0x000025d7 -[testViewController viewDidLoad] + 119
    6   UIKit                               0x0035e65e -[UIViewController view] + 179
    7   test                                0x0000237e -[testAppDelegate application:didFinishLaunchingWithOptions:] + 79
    8   UIKit                               0x002b11fa -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
    9   UIKit                               0x002b355e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
    10  UIKit                               0x002bddb2 -[UIApplication handleEvent:withNewEvent:] + 1533
    11  UIKit                               0x002b6202 -[UIApplication sendEvent:] + 71
    12  UIKit                               0x002bb732 _UIApplicationHandleEvent + 7576
    13  GraphicsServices                    0x016dda36 PurpleEventCallback + 1550
    14  CoreFoundation                      0x00d89064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    15  CoreFoundation                      0x00ce96f7 __CFRunLoopDoSource1 + 215
    16  CoreFoundation                      0x00ce6983 __CFRunLoopRun + 979
    17  CoreFoundation                      0x00ce6240 CFRunLoopRunSpecific + 208
    18  CoreFoundation                      0x00ce6161 CFRunLoopRunInMode + 97
    19  UIKit                               0x002b2fa8 -[UIApplication _run] + 636
    20  UIKit                               0x002bf42e UIApplicationMain + 1160
    21  test                                0x0000230c main + 102
    22  test                                0x0000229d start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal:  "SIGABRT".
(gdb) 


推荐答案

c $ c> -ObjC -all_load 发送到OTHER_LINKER_FLAGS设置。如果这不是一个选项,您可以尝试直接使用SBJsonParser或SBJsonWriter对象,而不是类别方法。

Try adding -ObjC -all_load to the OTHER_LINKER_FLAGS setting. If that is not an option, you could try to use the SBJsonParser or SBJsonWriter objects directly rather than the category methods.

这篇关于iPhone应用程式的JSON错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆