Unterschied zwischen Post & Get-Methode im Json-Parsing in ios

Implementiere ich die JSON-Parsing wie folgt:

-(void)getallEvent
{        
    SBJSON *json = [SBJSON new];
    json.humanReadable = YES;
    responseData = [[NSMutableData data] retain];

    NSString *service = @"/GetAllVenue";

    NSString *str;
    str = @"Calagary";
    NSString *requestString = [NSString stringWithFormat:@"{\"CityName\":\"%@\"}",str];

    //NSLog(@"request string:%@",requestString);

    //   NSString *requestString = [NSString stringWithFormat:@"{\"GetAllEventsDetails\":\"%@\"}",service];
    NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];

    NSString *fileLoc = [[NSBundle mainBundle] pathForResource:@"URLName" ofType:@"plist"];
    NSDictionary *fileContents = [[NSDictionary alloc] initWithContentsOfFile:fileLoc];
    NSString *urlLoc = [fileContents objectForKey:@"URL"];
    urlLoc = [urlLoc stringByAppendingString:service];
    //NSLog(@"URL : %@",urlLoc);

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: urlLoc]];  
    NSString *postLength = [NSString stringWithFormat:@"%d", [requestData length]];
    [request setHTTPMethod: @"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody: requestData];

    //   self.connection = [NSURLConnection connectionWithRequest:request delegate:self];



    NSError *respError = nil;
    NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: nil error: &respError ];

    if (respError) 
    {
        NSString *msg = [NSString stringWithFormat:@"Connection failed! Error - %@ %@",
                         [respError localizedDescription],
                         [[respError userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]];   
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Check your network connection"  message:msg delegate:self cancelButtonTitle:@"OK" 
                                                  otherButtonTitles:nil];
        [alertView show];
        [alertView release];

    } 
    else
    {
        NSString *responseString = [[NSString alloc] initWithData:returnData encoding: NSUTF8StringEncoding];

        NSDictionary *results = [[responseString JSONValue] retain];
        //NSLog(@" %@",results);
        NSString *extractUsers = [[results objectForKey:@"d"] retain];
        NSDictionary *finalResult = [[extractUsers JSONValue] retain];
        NSLog(@"Final Results : %@",finalResult);
        listOfEvents = [finalResult objectForKey:@"List of Event details of given Venue"];

}

Mit diesem code, es verlangsamt die app. Wie kann ich das Parsen der json im hintergrund?
*Ist dieses Recht für die Post-Methode? was ist der Unterschied zwischen Post & Get-Methode?*

Gibt es eine andere Möglichkeit, um json zu Parsen?

InformationsquelleAutor user2526811 | 2013-07-25
Schreibe einen Kommentar