I am performing some string concatenation to create a database query. As part of this, I need to assign and re-assign NSString variable in order to append to it.
I am currently using this code:
NSString *retVal = [[NSString alloc]init];
NSString *concat = @"";
retVal = [NSString stringWithFormat:@"%@%@ myfield= 'myvalue'", retVal, concat];
Note that whenever retVal and concat hold "" (empty string), I get empty string back in retVal. This is definitely not expected as I should get " myfield= 'myvalue'".
What am I missing?
Update:
Here is last I tried:
NSMutableString * retVal = [[NSMutableString alloc] init];
NSString * concat = @"";
[retVal appendString:@"appendstring"];
NSLog(@"%@", retVal); // prints <object returned empty description>
[retVal appendString:concat];
[retVal appendString:@"appendstring1"];
NSLog(@"%@", retVal); // prints %@