某些JSON请求在adHoc上崩溃,但在调试时没有崩溃

时间:2009-10-30 15:38:30

标签: iphone json-framework

我正在使用json-framework与某些Web服务进行通信。到目前为止,它对我很有帮助。但是,此代码会在设备上崩溃我的adHoc应用。设备上调试模式下的相同应用程序运行正常。

这是我的JSON请求(崩溃的地方):

//Make values dictionary
NSMutableDictionary *valuesDictionary;
NSMutableDictionary *valuesDictionary_1;
NSMutableArray *tempArray;
NSMutableArray *values = [[NSMutableArray alloc] init];;
NSEnumerator * enumerator = [self.contactsTempArray objectEnumerator];
id tempObj;
while ( tempObj = [enumerator nextObject] ) {
    valuesDictionary = [[NSMutableDictionary alloc] init];
    valuesDictionary_1 = [[NSMutableDictionary alloc] init];
    tempArray = [[NSMutableArray alloc] init];
    //NSString *key = [NSString stringWithFormat:]
    if([[tempObj objectForKey:@"Checked"] isEqualToString:@"1"]) {
        [valuesDictionary setObject:[NSNumber numberWithInt:[[tempObj objectForKey:@"NotificationContactId"] intValue]] forKey:@"ContactId"];
        [valuesDictionary setObject:[NSNumber numberWithBool:true] forKey:@"IsEnabled"];
    }
    else {
        [valuesDictionary setObject:[NSNumber numberWithInt:[[tempObj objectForKey:@"NotificationContactId"] intValue]] forKey:@"ContactId"];
        [valuesDictionary setObject:[NSNumber numberWithBool:false] forKey:@"IsEnabled"];
    }
    [tempArray addObject:valuesDictionary];
    [tempArray addObject:valuesDictionary_1];
    [values addObject:valuesDictionary];
    [valuesDictionary release];

}

//UPDATE NOTIFICATIONS SETTINGS

//JSON POST request
NSArray *keys = [NSArray arrayWithObjects:@"sessionId", @"apiKey", @"deviceToken", @"values", nil];
NSArray *objects = [NSArray arrayWithObjects:appDelegate.sessionId, appDelegate.apiKey, appDelegate.deviceToken, values, nil];
NSDictionary *getAllSensorsDict = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
NSString *requestString = [NSString stringWithFormat:@"%@", [getAllSensorsDict JSONFragment], nil];
NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: @"https://xxxxxxxxx"]];
[request setValue:@"application/json;charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: requestData];
//JSON response
NSData *jsonData = [ NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil ];

任何想法我做错了什么?

对于adHoc,JSON请求是否过于复杂?

1 个答案:

答案 0 :(得分:0)

将iphone连接到Mac。然后打开xcode,打开菜单,窗口,组织者。转到“崩溃日志”并查看有关崩溃的信息......

或者你甚至可以使用Build and Go按钮在你的iphone(连接到mac)中测试你的应用程序。您将在控制台中看到崩溃消息。