lldb error: use of undeclared identifier

好久不见. 提交于 2020-01-14 19:50:53

问题


Anyone know whats going on here:

@implementation Test
{
    NSData *_data;
}

- (id)initWithData:(NSData *)data
{
    self = [super init];
    if (self)
    {
        _data = data;
    } 
    return self;  // BREAKPOINT HERE
}

From lldb:

(lldb) p data
(NSData *) $1 = 0x07f911e0 30308 bytes
(lldb) p _data
error: use of undeclared identifier '_data'
error: 1 errors parsing expression

Why can't I view _data?


回答1:


I've only ever seen data fields declared in an @interface block; you appear to be defining fields in the @implementation.

Try putting this in the header instead, e.g.

@interface Test
{
    NSData *_data;
}
. . .
@end


来源:https://stackoverflow.com/questions/11488361/lldb-error-use-of-undeclared-identifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!