views:

174

answers:

1

hello all im trying out the chapter 10 example on push notifications. dont know if anyone has read it, its a really great article on push notifications. the code seems fine, the only problem i have is when i use

NSString *registerResult = [NSString stringWithContentsOfURL:[NSURL URLWithString:getURLString]]; it give me a warning that it is depreciated in iPhone 3.0, so i searched for a change i found that

[NSString stringWithContentsOfURL:encoding:error:]

works with this but i do not know how to implement it with the code of this article could someone please show me an example how i could get this link to work with this app.

here is the reference code.

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]];

Thanks

+1  A: 

try the following

NSURL *url = [NSURL URLWithString:getURLString];

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

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