0
votes

My code is like this :

NSString *urlStr = [NSString stringWithFormat:@"https://xxx.xxx.xx.xx/Pages/Service/FMService.svc/FileAudit?user=%@&pass=%@&fileId=%d&isAudited=1&opinion=%@",appDelegate.user.userName,appDelegate.user.password,self.todo.fileId,self.opinion];
    NSLog(@"URL=%@",urlStr);        
    NSURL *url = [NSURL URLWithString:urlStr];

And the url = (NSURL *) 0*00000000@"< nil >"

how can I work it out? thank you in advance!

1
If even one part of that string is nil, then the whole thing gets messed up. Check that every one of its parts aren't nil. - CodaFi
Another reason could be a type mismatch, e.g., if fileId is an object and not an integer. - Matthias
encode urlstring. [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; - 0x8badf00d
Is it a existing sequence of your code? Or don't you call these strings in different places? - Gargo

1 Answers

2
votes

For debugging purposes, I would build up urlStr piece by piece instead of combining five NSStrings all at once. Put in an NSLog(@"%@", urlStr) statement after each addition to urlStr. This will reveal which piece of the puzzle is causing the problem.