How can I combine \"stringURL\" and \"stringSearch\" together?
- (IBAction)search:(id)sender;{
stringURL = @\"http://www.websitehere.com/index.php?s=\";
stri
I would not have given the answer of such general question. There are many answers of same type question have already given. First find the answer of your question from existing question.
NSString* myURLString = [NSString stringWithFormat:@"http://www.websitehere.com/index.php?s=%@", search.text];
Instead of stringByAppendingString:
, you could also use
NSString *combined = [NSString stringWithFormat: @"%@%@",
stringURL, stringSearch];
This is especially interesting/convenient if you have more than one string to append. Otherwise, the stringbyAppendingString:
method is probably the better choice.
You can use stringByAppendingString:
stringURL = [@"http://www.websitehere.com/index.php?s="
stringByAppendingString:search.text];
NSString* combinedString = [stringUrl stringByAppendingString: search.text];
If you want to have some control about the format of the parameter you should assemble your URL string with
[NSString stringWithFormat:@"http://www.websitehere.com/index.php?s=%@", search.text]
This solution is charming because you can append almost anything which can be inserted into a printf-style format.
NSString * combined = [stringURL stringByAppendingString:stringSearch];