Try to use stringWithFormat
NSString *resourceURL = [NSString stringWithFormat:@"https://api.soundcloud.com/tracks?client_id=546952635e22cc0182d85daceff34381&q=%@&format=json", searchWord];
質問
Basically I did this and I got an error:
NSString *searchWord = @"Lilwayne";
NSString *resourceURL = (@"https://api.soundcloud.com/tracks?client_id=546952635e22cc0182d85daceff34381&q=%@&format=json", searchWord);
Error is:
reason: 'Resource 'Lilwayne' is invalid because the scheme is not 'https'.'
I don't understand why this doesn't work. However if I remove the "%@" and replace it with "Lilwayne" it works.
The reason why I am doing it this way is because I have a search feature in my app to search for songs using the soundcloud sdk
and I want to dynamically change the value of the variable "searchword" to whatever the user typed in.
解決
Try to use stringWithFormat
NSString *resourceURL = [NSString stringWithFormat:@"https://api.soundcloud.com/tracks?client_id=546952635e22cc0182d85daceff34381&q=%@&format=json", searchWord];
他のヒント
I suggest a trip to the NSString class reference in the Xcode help system. In addition to stringWithFormat, as suggested by Basheer, There is a section on combining strings.