I have an object that is appending a local string to another, and then handing that to an instance variable. This StringObj is being held by the calling UITableViewController. On the first call, fullCmdString has the string correctly. However, on 2nd call, the fullCmdString is null, or full of weird data (looks like data in odd mem location). My best guess is that stringByAppendingString is returning a reference to inStr, and not a new NSString object, so the data is going out of scope. Can anyone shed some light on this?
#import "StringObj.h"
@synthesize fullCmdString;
- (void)assemble:(NSString *)inStr {
NSString *add = @"text added";
//doesn't hold onto string
fullCmdString = [NSString stringWithString:[inStr stringByAppendingString:add]];
//doesn't hold onto string either
fullCmdString = [inStr stringByAppendingString:add];
//works great
fullCmdString = @"basic text text added";
}