为什么在iphone中解析json时不调用NSURLDegresents方法

为什么在iphone中解析json时不调用NSURLDegresents方法,iphone,json,delegates,nsurlconnection,Iphone,Json,Delegates,Nsurlconnection,我正在从GooglePlacesAPI开发一个iphone应用程序。为此,我正在进行JSON解析以获取数据 对于JSON解析,我创建了一个类,并在其中编写了这些方法 在JsonParse.m文件中编写了以下方法: - (void)initWithURLString:(NSString *)aURLString parameter:(UIViewController *)viewController { NSURL *url = [NSURL URLWithString:aURLStri

我正在从GooglePlacesAPI开发一个iphone应用程序。为此,我正在进行JSON解析以获取数据

对于JSON解析,我创建了一个类,并在其中编写了这些方法 在
JsonParse.m
文件中编写了以下方法:

- (void)initWithURLString:(NSString *)aURLString parameter:(UIViewController *)viewController
{

    NSURL *url = [NSURL URLWithString:aURLString];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    connection=[[NSURLConnection alloc] initWithRequest:request delegate:viewController];

}

-(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
{
    label.text=[NSString stringWithFormat:@"error in the connection %@",[error    description]];
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
   NSString *responsestring=[[NSString alloc] initWithData:responseData  encoding:NSUTF8StringEncoding];

    NSLog(@"response string is %@",responsestring);

    NSError *error;
    SBJSON *json=[[SBJSON new]autorelease];
    NSMutableDictionary *response=[NSMutableDictionary dictionary];
    response=[json objectWithString:responsestring  error:&error];

    NSLog(@"values in the dictionary is %@",[response valueForKey:@"results"]);         
} 
我从
viewcontroller
类调用该方法,如下所示:

JsonParse *obj=[[JsonParse alloc] init];
[obj initWithURLString:urlstr parameter:self];
但当我只调试
initwithurl
方法时,不会调用其他连接委托方法。
以前我在同一个类中编写了方法,也就是在
viewcontroller
类中,当时调用了每个方法,我能够使用数据。
我在单独的类中编写了这个方法,因为在同一个
viewcontroller
类中,我想多次解析数据(使用不同的URL解析一次以上)

有人知道为什么不调用这些方法,或者我如何在同一个类中多次解析这些方法吗?有关于这方面的教程或示例代码吗?

在:

// the delegate must be self
connection=[[NSURLConnection alloc] initWithRequest:request
                                           delegate:viewController];
为了调用这些方法,委托应该是
self
,因为这些方法是在
JsonParse
中实现的