在iOS中发送JSON字符串并获得正确响应

在iOS中发送JSON字符串并获得正确响应,ios,json,nsurlrequest,Ios,Json,Nsurlrequest,我想向后端发送一个类似@“projects 02.03.2012”的字符串,并接收一个json响应,其中包含根据我发送的字符串选择的项目列表。后端将为我做,但我想知道请求url应该是什么样子,我是否会收到正确的响应。这是我到目前为止得到的,请求url只是为了测试 -(void)requestProjects { responseData=[[NSMutableData alloc] init]; responseArray=[[NSMutableArray alloc] init

我想向后端发送一个类似@“projects 02.03.2012”的字符串,并接收一个json响应,其中包含根据我发送的字符串选择的项目列表。后端将为我做,但我想知道请求url应该是什么样子,我是否会收到正确的响应。这是我到目前为止得到的,请求url只是为了测试

-(void)requestProjects
{
    responseData=[[NSMutableData alloc] init];
    responseArray=[[NSMutableArray alloc] init];
    NSURLRequest *request = [NSURLRequest requestWithURL:
                             [NSURL URLWithString:@"http://search.twitter.com/search.json?q=mobtuts&rpp=5"]];
    NSURLConnection *connection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
    [connection start];
}

#pragma mark NSURLConnection delegate methods
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    [responseData setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [responseData appendData:data];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
    NSLog(@"Connection failed!");
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {

    NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];


    NSDictionary *results = [responseString JSONValue];
    NSLog(@"Response: %@", results);
}

控制台输出是什么样子的?请参见以下内容。希望有帮助。不管它看起来如何,因为它是一个来自教程的假URL。谢谢,弗莱斯,你今天第二次帮我了