Beginner: Why do I get a EXC BAD ACCESS? [closed]

雨燕双飞 提交于 2019-12-24 17:28:31

问题


I am geting an exception while hitting the line "self.myData = ..."

GDB Program received signal: EXC_BAD_ACCESS

Here's my code:

- (void)viewDidLoad {
    [super viewDidLoad];    
    self.myData = [NSArray arrayWithObjects:
                   [NSArray arrayWithObjects: 
                    @"Boroughs", 
                    [NSArray arrayWithObjects: 
                     @"Kings", 
                     @"Bronx", 
                     @"Manhattan", 
                     @"Queens", 
                     @"Staten Island", 
                     nil], 
                    nil],
                   [NSArray arrayWithObjects: 
                    @"Surrounding Counties", 
                    [NSArray arrayWithObjects: 
                     @"Westchester", 
                     @"Nassau", 
                     @"Suffolk", 
                     "@Fairfield", 
                     nil], 
                    nil],
                   nil];
}

回答1:


I'd say your problem is with the string "@Fairfield", unless that is a typo here and correct in your source file.




回答2:


If you want those arrays to continue to exist after -viewDidLoad, then they have to be retained. Did you synthesize an accessor for "myData"? Let's see the @property and @synthesize lines.



来源:https://stackoverflow.com/questions/1656287/beginner-why-do-i-get-a-exc-bad-access

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