1
Bonjour Quelqu'un pourrait-il me aider à mettre à jour ce snippent à iOS 4.2:stringWithContentsOfURL déprécié, aider à mettre à jour à 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];}
La seule partie qui a besoin d'une mise à jour est ci-dessous, vous pouvez effectivly oublier le reste:
NSData *htmlData = [[NSString stringWithContentsOfURL:[NSURL URLWithString: @"http://www.objectgraph.com/contact.html"]] dataUsingEncoding:NSUTF8StringEncoding];
"stringWithContentsOfURL" a été déprécié alors quelle serait la version mise à jour?
Merci
Branchez simplement que dans le code ci-dessus? avec le "+" ??? Merci de votre aide. –
Je ne sais pas comment vous avez écrit le code ci-dessus si vous ne savez pas ce que le "+" signifie ici ... Vous devriez regarder: http://developer.apple.com/library/mac/#referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/ – gcamp
excuse mon ignorance, c'est une application slapdash, comment pourrais-je mettre en œuvre ce qui précède? Je ne connais pas bien l'objectif c, j'apprends simplement à partir d'exemples. –