gpt4 book ai didi

objective-c - viewDidLoad 中的 EXC_BAD_ACCESS

转载 作者:行者123 更新时间:2023-12-03 17:30:24 24 4
gpt4 key购买 nike

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
@try {
if ([segue.identifier isEqualToString:@"taskListSegue"])
{
MindMapInformationViewController_iPhone *taskListContentController = [segue destinationViewController];
int selectedIndexPath = [[self.tableView indexPathForSelectedRow] row];

MindMap *newMindMap;
newMindMap = [mindmaps objectAtIndex:selectedIndexPath];
FileManager *fileManager = [[[FileManager alloc] init] autorelease];
[fileManager readFile:newMindMap.pathToMindmapAtDevice parsing:YES];

NSMutableArray *taskArray = [fileManager getArray];
[taskListContentController setTasksOfSelectedMindmap:taskArray];
}
}
@catch (NSException *exception) {

}
}

-(void)setTasksOfSelectedMindmap:(NSMutableArray *)tasks {
@try {
[self initComponents];
if (tasks != nil) {
taskArray = tasks;
}
}
@catch (NSException *exception) {

}

}

-(void)initComponents {
@try {
taskArray = [[NSMutableArray alloc] init];

taskName = [[NSMutableArray alloc] init];
taskOwner = [[NSMutableArray alloc] init];
}
@catch (NSException *exception) {

}
}

-(void)viewDidLoad
{
@try {
[super viewDidLoad];
int i = 0;
for (MindMapTask *newTask in taskArray) {
if (newTask.taskOwner == nil) {
newTask.taskOwner = @"Keine Angabe";
}
[taskName addObject:newTask.taskTitle];
[taskOwner addObject:newTask.taskOwner];

i++;
}

}
@catch (NSException *exception) {
NSLog(@"Exception - %@", exception);
}
}

为什么我获得EXC_BAD_ACCESS?这个异常的产生者似乎是[super viewDidLoad]; ...

有人可以帮助我吗? :)

编辑:稍微更改了代码..希望它可以理解

您可以看到,我将数组的定义移到了自己的方法中。我还添加了一个方法来确保 taskTitle 不为零(在其他类中)。

最佳答案

尝试放置

[super viewDidLoad];

作为第一个声明。

关于objective-c - viewDidLoad 中的 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9278829/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com