How to add string variables using stringWithFormat method in Objective-C

I want to add a string to single varilable using stringWithFormat.I knew this when using stringByAppendingString. Please help me add the code below using stringWithFormat.

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

Thank you Madan Mohan.

+7
append objective-c stringwithformat
source share
1 answer

You can build your curl string using the -stringWithFormat: method:

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

All Articles