NSMutable String "Out of scope"

Posted by Garry on Stack Overflow See other posts from Stack Overflow or by Garry
Published on 2010-03-27T13:04:53Z Indexed on 2010/03/27 13:13 UTC
Read the original article Hit count: 327

I have two NSMutableString objects defined in my viewController's (a subclass of UITableViewController) .h file:

NSMutableString *firstName;
NSMutableString *lastName;

They are properties:

@property (nonatomic, retain) NSMutableString *firstName;
@property (nonatomic, retain) NSMutableString *lastName;

I synthesis them in the .m file.

In my viewDidLoad method - I set them to be blank strings:

firstName = [NSMutableString stringWithString:@""];
lastName = [NSMutableString stringWithString:@""];

firstName and lastName can be altered by the user. In my cellForRowAtIndexPath method, I'm trying to display the contents of these strings:

cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ %@", firstName, lastName];

but this is causing the app to crash as soon as the view controller is displayed. Using the debugger, it seems that both firstName and lastName are "out of scope" or that they don't exist. I'm new to Xcode but the debugger seems to halt at objc_msgSend.

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c