我有时会遇到 SIGABRT 崩溃,崩溃时说:GKScore 必须包含一个初始化值。
所以它追踪到这一行:
[localScore reportScoreWithCompletionHandler:^(NSError* error) {}];
localStore 是这样创建的:
GKScore* localScore = [scores objectForKey:category];
-- 类别来自...
for (NSString* category in categories)
-- 类别来自...
[GKLeaderboard loadCategoriesWithCompletionHandler:^(NSArray *categories, NSArray *titles, NSError *error)
-(void) initScores
{
NSString* libraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* file = [libraryPath stringByAppendingPathComponent:currentPlayerID];
file = [file stringByAppendingString:kScoresFile];
id object = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if ([object isKindOfClass:[NSMutableDictionary class]])
{
NSMutableDictionary* loadedScores = (NSMutableDictionary*)object;
scores = [[NSMutableDictionary alloc] initWithDictionary:loadedScores];
}
else
{
scores = [[NSMutableDictionary alloc] init];
}
//NSLog(@"scores initialized: %d", scores.count);
}
对不起所有的代码,但几乎所有这些代码都来自这个库的文件:https ://github.com/csdavies/DDGameKitHelper/blob/master/DDGameKitHelper.m
无论如何,我将如何解决这个问题?
谢谢!!!