iphone sdk - 预期标识符错误

时间:2011-07-29 04:13:56

标签: iphone xcode nsurl

我正在尝试加载一个网址,其中输入字段的值已添加到网址的末尾,并且错误地显示为“预期的识别符号”:(

[self fetchURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://localhost/test/script.php?name=%@&",[[urlField text]]]];

我做错了什么?

1 个答案:

答案 0 :(得分:0)

你错过了支架

[self fetchURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://localhost/test/script.php?name=%@&",[[urlField text]]]]];

或尝试改为

    NSString *urlString = [NSString stringWithFormat:@"http://localhost/test/script.php?name=%@&",[urlField text]];
    NSURL *url = [NSURL URLWithString:urlString];
    [self fetchURL:url];