我已经转换了一个用Objective-C编写的应用程序,之前使用的是SQL,现在改为CoreData。
问题我确定到目前为止我只在一个班级中将NSObject
更改为NSManagedObject
我在ViewController
被View
完全解散后在[self dismissViewControllerAnimated:YES completion:nil];
中遇到了这个愚蠢的崩溃:
@implementation Viewcontroller
控制在NSObject
处停止,如果我将此类中使用的模型更改回// Action script...
// [Initial MovieClip Action of sprite 2248]
#initclip 12
class gameData
{
var PLAYERID, PLAYERNAME, LASTMODIFIED, DIFFICULTY, CLEVEL, MONEY, AMMO_TOTAL, POINTS;
function gameData(_PLAYERNAME)
{
var _loc2 = new Date();
PLAYERID = String(_loc2.getTime());
PLAYERID = PLAYERID + String(Math.round(Math.random() * 99999));
PLAYERNAME = _PLAYERNAME;
LASTMODIFIED = new Date();
DIFFICULTY = 1;
CLEVEL = 1;
MONEY = 0;
AMMO_TOTAL = [60000, 0, 0, 0, 0, 0];
POINTS = 0;
} // End of the function
static function saveGame(_GAME)
{
_global.CGAME.LASTMODIFIED = new Date();
gameData.saveGames(_global.GAMES);
} // End of the function
static function saveGames(_GAMES)
{
var _loc1 = SharedObject.getLocal(gameData.GAMEID);
_loc1.data.GAMES = _GAMES;
_loc1.flush();
} // End of the function
static function newGame(_NAME, _DIFFICULTY)
{
var _loc1 = SharedObject.getLocal(gameData.GAMEID);
var _loc2 = _loc1.data.GAMES;
if (_loc2 == undefined)
{
_loc1.data.GAMES = new Array();
} // end if
var _loc3 = new gameData(_name, _DIFFICULTY, _loc2.length);
_loc1.data.GAMES.push(_loc3);
_loc1.flush();
} // End of the function
static function deleteGame(_INDEX)
{
var _loc1 = SharedObject.getLocal(gameData.GAMEID);
var _loc2 = _loc1.data.GAMES;
if (_INDEX < 0)
{
return;
} // end if
if (_INDEX > _loc2.length - 1)
{
return;
} // end if
_loc2.splice(_INDEX, 1);
_loc1.flush();
} // End of the function
static function getGames()
{
var _loc1 = SharedObject.getLocal(gameData.GAMEID);
var _loc2 = _loc1.data.GAMES;
if (_loc2 == undefined)
{
_loc1.data.GAMES = [];
_loc1.flush();
} // end if
return (_loc1.data.GAMES);
} // End of the function
static var GAMEID = "qigames_13DaysNightmare_12";
} // End of Class
#endinitclip
,则没有崩溃,视图将被正确解除。
到目前为止,我还没有发现这次崩溃甚至意味着什么?
有没有办法调试这个?
答案 0 :(得分:1)
我也遇到过类似的问题,下面的代码添加到dealloc解决了我的问题。
-(void) dealloc {
[_managedObjectContext reset];
}
OR
-(void) dealloc {
_objectFromContext = nil;
_managedObjectContext = nil;
}
有关详细信息,请参阅此link
希望它对你有所帮助。
答案 1 :(得分:0)
导致[UIViewController .cxx_destruct]
Article *article = [Article new];
已修复此
NSManagedObject *article = [NSEntityDescription insertNewObjectForEntityForName:@"Article"
inManagedObjectContext:context];