开发者

Certain JSON requests crach on adHoc, but not on debug

I am using json-framework for communication purposes with certain web service. So far it has served me well. However, this code crashes my adHoc app on the device. The same app in debug mode on the device works ok.

Here is my JSON request(that is where it crashes):

//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:]开发者_如何学C
    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 ];

any ideas what am I doing wrong?

Is the JSON request too complex for adHoc?


Connect your iphone to your mac. Then open xcode, open menu, window, organizer. There go to "crash logs" and look the info about the crash....

Or you can even test your app in your iphone (connected to the mac) using the Build and Go button. You will see the crash messages in the console.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜