iOS项目中未知的接收者'jsonParser'错误

时间:2012-04-18 11:52:54

标签: objective-c ios json facebook-graph-api

我在下面的代码中遇到了一些错误。错误是'使用未声明的标识符'SBJSON'和'未知接收者'jsonParser',你的意思是SBJsonParser'?

我的项目中有JSON库。它正在使用Facebook Graph API和Google Places。出于某种原因,虽然下面的代码(也适用于Facebook API)没有找到JSON文件。知道为什么吗?我想知道我是否将它们拖放到项目中不正确或其他什么。

感谢您的帮助。

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
        [self hideActivityIndicator];

        NSString* responseString = [[[NSString alloc] initWithData:receivedData
                                                          encoding:NSUTF8StringEncoding]
                                    autorelease];
        NSLog(@"Response from photo upload: %@",responseString);
        [self clearConnection];
        // Check the photo upload server completes successfully
        if ([responseString rangeOfString:@"ERROR:"].location == NSNotFound) {
            SBJSON *jsonParser = [[SBJSON new] autorelease];
            id result = [jsonParser objectWithString:responseString];
            // Look for expected parameter back
            if ([result objectForKey:@"image_name"]) {
                productImageData = [result copy];
                // Now that we have successfully uploaded the photo
                // we will make the Graph API call to send our Wishlist
                // information.
                [self apiGraphAddToWishlist];
            } else {
                [self showAlertErrorMessage:@"Could not upload the photo." ];
            }
        } else {
            [self showAlertErrorMessage:@"Could not upload the photo." ];
        }
    }

Included a screenshot showing the JSON library in the project and the errors

2 个答案:

答案 0 :(得分:3)

而不是使用

SBJSON *jsonParser

使用:

SBJsonParser *jsonParser;

答案 1 :(得分:1)

enter image description here

请确保您的项目中包含此文件,并且所有.m文件都位于目标的“编译源”列表中。

还要确保您引用的文件正在导入SBJSON.h:

#import "SBJSON.h"