I have to classes A and B . My B class having the method for connection with the server. I am calling this method from class A.I have implemented the delegate for NSURLConnection.class A having check connectivity function which is having the return type as a BOOL . I am invoking the ping method of class B from this method as follow:
class A:
-(BOOL)checkConnectivity:(Server *)newServer
{
[b ping];
return FALSE;
}
class B:
-(void)ping
{
NSURL *url=[[NSURL alloc]initWithString:@"my url"];
request=[NSMutableURLRequest requestWithURL:url];
connection=[[NSURLConnection alloc]initWithRequest:request delegate:self];
if(connection)
{
webData=[NSMutableData data];
}
}
-(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *) data
{
[webData appendData:data];
}
-(void) connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"Finished loading");
}
there is no issue with the url. Then whats wrong?why delegate methods are not invoking ?
Check u have added this:
Now do this in your ping method: