NSString 和连接的问题
为什么这段代码给我以下错误?
“使用未声明的标识符baseURL”
和
“意外的接口名称 NSString,预期的表达式”
这里是整个代码块
switch (type) {
case 1:
NSString *baseURL = [NSString stringWithString:@"http://www.myserver.net/somephp/"];
NSString *finalURL = [baseURL stringByAppendingString:@"?i="];
break;
case 2:
NSString *finalURL = [baseURL stringByAppendingString:@"?n="];
break;
default:
break;
}
Why this code gives me the following errors?
"use of undeclared identifier baseURL"
and
"Unexpected Interface name NSString, expected expression"
here is the entire block of code
switch (type) {
case 1:
NSString *baseURL = [NSString stringWithString:@"http://www.myserver.net/somephp/"];
NSString *finalURL = [baseURL stringByAppendingString:@"?i="];
break;
case 2:
NSString *finalURL = [baseURL stringByAppendingString:@"?n="];
break;
default:
break;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来这些行位于 switch 语句内。如果是这种情况,请将字符串声明移到
switch
语句之外。有关解决此问题的更多信息和其他技术此问题。
Sounds like those lines are within a
switch
statement. If this is the case, move the declaration of the strings outside theswitch
statement.More information and other techniques to work around this on this question.