Core Data Predicate Excepton: Unsupported expression type (11, SIZE)

Origin: http://shiki.me/blog/core-data-error-unsupported-expression-type-11-size/

 

Yeah, so I’ve been learning Core Data and I keep getting this error during a fetch request:

Name: NSInvalidArgumentException
File: Unknown
Line: Unknown
Reason: Unsupported expression type (11, SIZE)

An obscure error message, yay! This happened when I used this very simple predicate declaration:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"size == %@", @"medium"];

Like one of those bad days, Google doesn’t help. It took me an hour or two to figure out that size is a reserved word in Core Data. Epic fail. You can fix this by escaping size using a hash (#):

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"#size == %@", @"medium"];

posted on 2014-08-04 12:00  课蜜黄蜂  阅读(244)  评论(0编辑  收藏  举报