Resolved...
It was down to a couple of lines of code...
NSString *displayString = [NSString stringWithFormat:@"Set by %@", [self title]];
[appDelegate setModelData:displayString];
I've come from an ActionScript background and to me, referencing displayString would prevent it from being trashed. However, in objective-c this is not the case and NSString stringWithFormat is an autorelease method so when subViewOne was trying to get the string, [appDelegate getModelData] was pointing to invalid data because garbage collection had cleared the object created with NSString stringWithFormat.
I hope you are following this.
The resolution was to change NSString stringWithFormat to this...
NSString *displayString = [[NSString alloc] initWithFormat:@"Set by %@", [self title]];
[appDelegate setModelData:displayString];
and clear any existing pointers in the setModelData method...
-(void) setModelData : (NSString *) newData {
if (modelData != nil)
{
[modelData release];
}
modelData = newData;
}
I suspect there will be more memory management lessons coming my way