我正在尝试撰写动态网址,除了这样做之外,还有更简单的方法来追加字符串吗?这似乎效率低下。
NSString *folder1 = @"sonic";
NSString *folder2 = @"usr";
NSString *url = @"http://www.mydomain.com";
url = [url stringByAppendingFormat:@"/"];
url = [url stringByAppendingFormat:folder2];
url = [url stringByAppendingFormat:@"/"];
url = [url stringByAppendingFormat:folder1];
答案 0 :(得分:2)
可能:
NSString *url = [NSString stringWithFormat:@"http://www.mydomain.com/%@/%@", folder2, folder1];