reg*_*cob 0 cocoa exc-bad-access objective-c super viewdidload
- (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);
}
}
Run Code Online (Sandbox Code Playgroud)
为什么我会得到EXC_BAD_ACCESS?这个异常的产生者似乎是[super viewDidLoad]; ...
谁能帮我 ?:)
编辑:稍微改变了代码..希望它可以理解
您可以看到,我将数组的定义移到了自己的方法中。我还添加了一个方法来确保 taskTitle 不为零(在其他类中)。
| 归档时间: |
|
| 查看次数: |
883 次 |
| 最近记录: |