1
你好 誰能幫我更新此snippent到iOS 4.2:stringWithContentsOfURL折舊,有助於更新到4.2?
-(void) whatever{
NSData *htmlData = [[NSString stringWithContentsOfURL:[NSURL URLWithString: @"http://www.objectgraph.com/contact.html"]] dataUsingEncoding:NSUTF8StringEncoding];
TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:htmlData];
NSArray *elements = [xpathParser search:@"//h3"]; // get the page title - this is xpath notation
TFHppleElement *element = [elements objectAtIndex:0];
NSString *myTitle = [element content];
NSLog(myTitle);
[xpathParser release];
[htmlData release];}
需要更新是下面的只是一部分,你可以用途不同忘記休息:
NSData *htmlData = [[NSString stringWithContentsOfURL:[NSURL URLWithString: @"http://www.objectgraph.com/contact.html"]] dataUsingEncoding:NSUTF8StringEncoding];
「stringWithContentsOfURL」已deprechiated所以什麼是更新的版本?
感謝
只是把它插入到上面的代碼?與「+」?謝謝你的幫助。 – 2010-12-04 00:16:41