Parse.com:[task.results filteredArrayUsingPredicate] 抛出 objec_exception_thrown 和 Xcode 7
Parse.com: [task.results filteredArrayUsingPredicate] throws objec_exception_thrown with Xcode 7
以下代码在 iOS 8 和 Xcode 6 上运行良好,但在 iOS 8 和 Xcode 7 上编译时在调试中抛出 objec_exception_thrown和 iOS 9. 我正在为 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(串行))。
知道如何解决这个问题吗?它看起来只有在调试模式下 运行 时才会抛出异常。
这是堆栈跟踪:
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
私有 ivar。
如果您在 results
数组中获得的对象有一个 level_num
属性,您的谓词应该只是 :
NSPredicate *betweenPredicate = [NSPredicate predicateWithFormat:@"level_num BETWEEN {%d,%d}", firstLevelInSection, lastLevelInSection];
以下代码在 iOS 8 和 Xcode 6 上运行良好,但在 iOS 8 和 Xcode 7 上编译时在调试中抛出 objec_exception_thrown和 iOS 9. 我正在为 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(串行))。
知道如何解决这个问题吗?它看起来只有在调试模式下 运行 时才会抛出异常。
这是堆栈跟踪:
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
私有 ivar。
如果您在 results
数组中获得的对象有一个 level_num
属性,您的谓词应该只是 :
NSPredicate *betweenPredicate = [NSPredicate predicateWithFormat:@"level_num BETWEEN {%d,%d}", firstLevelInSection, lastLevelInSection];