I found a tutorial on the net that uses the stringWithContentsOfURL command that is now deprecated as of iPhone OS 3.0. However I can\'t find out what I\'m meant to use inst
Thanks Greg, but for all those other beginners here is an example
NSError* error = nil;
NSString* text = [NSString stringWithContentsOfURL:TheUrl encoding:NSASCIIStringEncoding error:&error];
if( text )
{
NSLog(@"Text=%@", text);
}
else
{
NSLog(@"Error = %@", error);
}
For anything more than trivial, I recommend ASIHTTPRequest:
http://allseeing-i.com/ASIHTTPRequest/
It has been replaced with stringWithContentsOfURL:encoding:error:
or stringWithContentsOfURL:usedEncoding:error:
.
Below code will remove your warning message........any question please let mo know.
- (void) connectedToNetwork
{
BOOL aflag = ([NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.google.co.in/"] encoding:NSASCIIStringEncoding error:nil]!=NULL)?YES:NO;
if (!aflag) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Sorry!....You are not connected to network "
delegate:self cancelButtonTitle:@"Exit" otherButtonTitles:nil];
[alert show];
[alert release];
}
}