What is the “stringWithContentsOfURL” replacement for objective C?

后端 未结 4 768
刺人心
刺人心 2020-12-13 19:04

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

4条回答
  •  渐次进展
    2020-12-13 19:31

    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);
    }
    

提交回复
热议问题