有问题。这里是我的代码:stringByReplacingOccurrencesOfString不按预期方式工作
Latitude = [TBXML textForElement:lat]; //Latitude & Longitude are both NSStrings
Longitude= [TBXML textForElement:lon];
NSLog(@"LAT:%@ LON:%@",Latitude,Longitude);
NSString *defaultURL = @"http://api.wxbug.net/getLiveWeatherRSS.aspx?ACode=000000000&lat=+&long=-&unittype=1";
newURL = [[defaultURL stringByReplacingOccurrencesOfString:@"+"
withString:Latitude]
stringByReplacingOccurrencesOfString:@"-"
withString:Longitude];
NSLog(@"%@",newURL);
而这里的输出:
LAT:-33.92 LON:18.42
http://api.wxbug.net/getLiveWeatherRSS.aspxACode=000000000&lat=18.4233.92&long=18.42&unittype=1
正如你可以看到,一些奇怪的事情正在发生的附加码。我在这里做错了什么?
谢谢,现在一切都清楚了。 :)我会照你的建议去做,并将占位符更改为更清晰的值。谢谢! – 2011-02-17 18:22:23