Я пытаюсь извлечь информацию из базы данных SQLlite с помощью Core Data и сразу же после того, как вы оставите IBAction, которые получают NSManageObject из БД, сбой приложения только с ошибкой EXEC_BAD_ACCESS.Получение EXEC_BAD_ACCES после выхода из IBAction
Код исполненное:
- (IBAction)abrir:(id)sender{
[openBrowser setTag:[sender tag]];
[self showOpenPanel:mWindow];
if (acceptCancelButton) {
NSString *auxN;
NSPredicate *auxP;
NSFetchRequest *auxFR;
NSError *err;
NSArray *array;
switch ([sender tag]) {
case 1:
auxN = [[[openBrowser selectedCell] stringValue] copy];
auxP =[NSPredicate predicateWithFormat:@"studyName == %@", auxN];
auxFR = [[NSFetchRequest alloc] init];
[auxFR setPredicate:auxP];
[auxFR setEntity:[NSEntityDescription entityForName:@"Study" inManagedObjectContext:managedObjectContext]];
[auxFR setIncludesSubentities:NO];
[auxFR setFetchLimit:1];
array = [managedObjectContext executeFetchRequest:auxFR error:&err];
if(array){
/*
Instanciamos un nuevo nsmanagedobject y lo cargamos con la información
leida de la BD
*/
actualStudy = [NSEntityDescription insertNewObjectForEntityForName:@"Study" inManagedObjectContext:managedObjectContext];
[actualStudy setValue:[[array objectAtIndex:0] valueForKey:@"studyName"] forKey:@"studyName"];
[actualStudy setValue:[[array objectAtIndex:0] valueForKey:@"studyPath"] forKey:@"studyPath"];
[actualStudy setValue:[[array objectAtIndex:0] valueForKey:@"studyDescription"] forKey:@"studyDescription"];
[actualStudy setValue:[[array objectAtIndex:0] valueForKey:@"compressRate"] forKey:@"compressRate"];
[actualStudy setValue:[[array objectAtIndex:0] valueForKey:@"testDuration"] forKey:@"testDuration"];
NSLog(@"%@ %@ %@ %d %d",
[actualStudy valueForKey:@"studyName"],
[actualStudy valueForKey:@"studyPath"],
[actualStudy valueForKey:@"studyDescription"],
[[actualStudy valueForKey:@"compressRate"] floatValue],
[[actualStudy valueForKey:@"testDuration"] intValue]);
}else{
[Auxiliar showError:-15];
}
break;
...
}
}
}
- actualStudy является переменной @interface исследования: NSManagedObject {
код выполнить нормально, но когда приложение возвращения из в этом случае:
The Debugger has exited with status 0.
[Session started at 2016-03-16 15:23:07 +0000.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".
tty /dev/ttys001
Loading program into debugger…
sharedlibrary apply-load-rules all
warning: Unable to read symbols from "CoreData" (not yet mapped into memory).
Program loaded.
run
[Switching to process 3574]
Running…
[Switching to process 3574]
[Switching to process 3574]
[Switching to process 3574]
[Switching to process 3574]
(gdb) continue
Current language: auto; currently objective-c++
(gdb) continue
2016-03-16 15:23:36.720 eTracker[3574:a0f] CoreData /Users/admin/usabilimac/build/Debug/CoreData/ Prueba core data 600 0
Program received signal: “EXC_BAD_ACCESS”.
(gdb)
Это ехес ворса:
#0 0x7fff88de6f10 in objc_msgSend
#1 0x7fff836101d6 in _CFAutoreleasePoolPop
#2 0x7fff86d3e110 in -[NSAutoreleasePool drain]
#3 0x7fff81e27723 in -[NSApplication run]
#4 0x7fff81e203b0 in NSApplicationMain
#5 0x1000027f1 in main at main.mm:13
Я только что обнаружил, что проблема, с которой этот управляемый контекст контекста вызывает выпуск по массиву, и когда оставить IBAction другой релиз, он отправляется на объект массива. Как я могу избежать этого? –