Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "out of scope" mean in Xcode debugger (for iPhone)?

I'm loading a detailed view of an article when clicking on a row in a UITableView. When clicked, it loads the object with the data and I pass that object to the next controller being pushed on the stack. However, when I do this:

- (void)showArticle
{
    [aTitle setText:[[self article] title]];
    [aTitle setBackgroundColor:[UIColor clearColor]];
    [[self view] addSubview:aTitle];

    [aCategory setText:[[self article] category]];
    [aCategory setBackgroundColor:[UIColor clearColor]];
    [[self view] addSubview:aCategory];

    [aAuthors setText:[[self article] authors]];
    [aAuthors setBackgroundColor:[UIColor clearColor]];
    [[self view] addSubview:aAuthors];
}

The title shows up fine, but the category and authors aren't showing up. When I debug, I'm getting "out of scope" when I look at the values of the category/authors. The article object is being @synthesized and I've checked it and it has the right data.

Any ideas? Does that mean that a method is private or something?

Thanks!

like image 528
rpheath Avatar asked Feb 25 '23 21:02

rpheath


2 Answers

It means the debugger couldn't see it when it tried to query its value. Sometimes that means the variable really is out of scope in the sense that it belongs to a C block you are not in. But there is a glitch where sometimes Objective-C objects, particularly NSStrings appear out of scope when they are really perfectly OK. It's almost never (in my experience) a programming error.

Try right clicking the variable and selecting "print description to console" if you need to see what the real value is.

like image 60
JeremyP Avatar answered Mar 05 '23 04:03

JeremyP


After a longtime to workaround this issue, you should use an object when assign to userData event NSString like this:

@interface callBackData
 @NSString *text;
 @NSInteger point;
@end

use it:

callBackData *data = [[callBackData alloc] init];
data.text=[NSString stringWithString:@"something"];
something.userData = data;

And you'll be always OK.

Pls remember do not assign directly NSString for userData, because of sometime it will be out of scope without reason

like image 34
vnone Avatar answered Mar 05 '23 03:03

vnone