在ios中调用web接口

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithWebRoute:@"interface/categories"]]];
       NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
       NSError *error;
       responseHash = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];

ps:stringWithWebRoute 是一个自定义的方法
+(NSString)stringWithWebRoute:(NSString)route
{
return [NSString stringWithRoute:route domainName:WEB_SERVER andId:YES];
}
后面接的是web接口的地址