我想使用stringWithFormat将字符串附加到单个varilable中。我在使用stringByAppendingString时知道它。请帮我使用stringWithFormat为下面的代码添加。
NSString* curl = @"https://invoices?ticket=";
curl = [curl stringByAppendingString:self.ticket];
curl = [curl stringByAppendingString:@"&apikey=bfc9c6ddeea9d75345cd"];
curl = [curl stringByReplacingOccurrencesOfString:@"\n" withString:@""];
谢谢你, Madan Mohan。
答案 0 :(得分:14)
您可以使用curl
方法构建-stringWithFormat:
字符串:
NSString *apiKey = @"bfc9c6ddeea9d75345cd";
NSString* curl = [NSString stringWithFormat:@"https://invoices?ticket=%@&apikey=%@", self.ticket, apiKey];