开发者

How to append the string variables using stringWithFormat method in Objective-C

开发者 https://www.devze.com 2023-01-03 20:51 出处:网络
I want to append the string into single varilable using stringWithFormat.开发者_JAVA百科I knew it in using stringByAppendingString. Please help me to append using stringWithFormat for the below code.

I want to append the string into single varilable using stringWithFormat.开发者_JAVA百科I knew it in using stringByAppendingString. Please help me to append using stringWithFormat for the below code.

NSString* curl = @"https://invoices?ticket=";
curl = [curl stringByAppendingString:self.ticket];
curl = [curl stringByAppendingString:@"&apikey=bfc9c6ddeea9d75345cd"];
curl = [curl stringByReplacingOccurrencesOfString:@"\n" withString:@""];

Thank You, Madan Mohan.


You can construct your curl string using -stringWithFormat: method:

NSString *apiKey = @"bfc9c6ddeea9d75345cd";
NSString* curl = [NSString stringWithFormat:@"https://invoices?ticket=%@&apikey=%@", self.ticket, apiKey];
0

精彩评论

暂无评论...
验证码 换一张
取 消