2010-03-11 5 views
1

bonjour tous im essayer l'exemple du chapitre 10 sur les notifications push. Je ne sais pas si quelqu'un l'a lu, c'est un très bon article sur les notifications push. le code semble très bien, le seul problème que j'ai est quand j'utiliseEssayer l'exemple de notification push sur Advanced Iphone Projets "Apress"

NSString *registerResult = [NSString stringWithContentsOfURL:[NSURL URLWithString:getURLString]]; il me donne un avertissement qu'il est amorti dans l'iPhone 3.0, donc je recherche un changement j'ai trouvé que

[NSString stringWithContentsOfURL:encoding:error:] 

œuvres avec cela, mais je ne sais pas comment le mettre en œuvre avec le code de cet article pourrait quelqu'un s'il vous plaît montrez-moi un exemple comment je pourrais obtenir ce lien pour travailler avec cette application.

Voici le code de référence.

NSString *hostString = @"http://2push2.us/apress/apress.php"; 
NSString *nameString = @"2Push2Test"; 
NSString *argsString = @"%@?token=%@&cmd=reg&name=%@"; 
NSString *getURLString = [NSString stringWithFormat:argsString,hostString,tokenString,nameString]; 
NSString *registerResult = [NSString stringWithContentsOfURL:[NSURL URLWithString:getURLString]]; 

Merci

Répondre

2

essayer le suivant

NSURL *url = [NSURL URLWithString:getURLString]; 

NSError *error = nil; 
NSString *registerResult = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error]; 

if (error) { 
    NSLog(@"Failure: %@", [error localizedDescription]); 
}