gpt4 book ai didi

ios - Parse.com : [task. 结果 filteredArrayUsingPredicate] 使用 Xcode 7 抛出 objec_exception_thrown

转载 作者:行者123 更新时间:2023-11-29 12:11:59 25 4
gpt4 key购买 nike

以下代码在带有 Xcode 6 的 iOS 8 上运行良好,但在 iOS 8 和 iOS 9 上使用 Xcode 7 编译时在调试中抛出 objec_exception_thrown。我正在为 iOS 使用 Parse 1.9.0 版。

 [[localQuery findObjectsInBackground] continueWithSuccessBlock:^id(BFTask *task) {

NSArray *results = task.result;
Level *level = [[LevelManager sharedManager] currentLevel];
int numberOfSolvedLevels = (int) [results count];
int levelNumber = (int)level.serialNumber;
int firstLevelInSection = ((levelNumber / LEVELSECTION_SIZE)*10);
int lastLevelInSection = firstLevelInSection + LEVELSECTION_SIZE;

// Get all the levels in the same range from the local query result
NSPredicate *betweenPredicate = [NSPredicate predicateWithFormat:@"estimatedData.level_num BETWEEN {%d,%d}", firstLevelInSection, lastLevelInSection];
// Throws objec_exception_thrown
NSArray *playedLevelsInBetweenRangeArray = [results filteredArrayUsingPredicate:betweenPredicate];
....
return task;
}];

这里抛出异常:

 NSArray *playedLevelsInBetweenRangeArray = [results filteredArrayUsingPredicate:betweenPredicate];

异常在解析线程中抛出(队列:com.parse-sqlitedb.queue (serial))。

任何信息如何解决这个问题?它看起来只有在 Debug模式下运行时才会抛出异常。

这是堆栈跟踪:

Thread 16Queue : com.parse.sqlite.db.queue (serial)
#0 0x000000019a277f48 in objc_exception_throw ()
#1 0x0000000185878c1c in -[NSException raise] ()
#2 0x000000018677dd90 in -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] ()
#3 0x00000001866d00cc in -[NSObject(NSKeyValueCoding) valueForKey:] ()
#4 0x00000001866cff68 in -[NSObject(NSKeyValueCoding) valueForKeyPath:] ()
#5 0x0000000186712cec in -[NSFunctionExpression expressionValueWithObject:context:] ()
#6 0x00000001867127d0 in -[NSComparisonPredicate evaluateWithObject:substitutionVariables:] ()
#7 0x0000000186711728 in _filterObjectsUsingPredicate ()
#8 0x0000000186711524 in -[NSArray(NSPredicateSupport) filteredArrayUsingPredicate:] ()

这是我唯一真实的调试信息:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<PFObjectEstimatedData 0x135b57f60> valueForUndefinedKey:]: this class is not key value coding-compliant for the key level_num.'

最佳答案

抛出异常是因为你的betweenPredicate无效。您不应尝试访问 estimatedData,这是一个 PFObject 私有(private) ivar。

如果您在 results 数组中获得的对象具有 level_num 属性,则您的谓词应该只是:

NSPredicate *betweenPredicate = [NSPredicate predicateWithFormat:@"level_num BETWEEN {%d,%d}", firstLevelInSection, lastLevelInSection];

关于ios - Parse.com : [task. 结果 filteredArrayUsingPredicate] 使用 Xcode 7 抛出 objec_exception_thrown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33185579/

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