내가 가지고 내가 type
특성에 술어를 적용 할 필요가 Section
객체 술어 - 신속한
class Section: NSObject {
enum SectionType : String {
case Name = "NAME"
case Address = "ADDRESS"
case Phone = "PHONE"
}
var type : SectionType = .Name
}
의 배열
let predicate = NSPredicate(format: "SELF.type == %d", SectionType.Name.rawValue)
let filteredArray = (preferenceSections as NSArray).filteredArrayUsingPredicate(predicate) //CRASH
if filteredArray.count > 0 {
}
앱이 Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Mobile.Section 0x7fb120d33c50> valueForUndefinedKey:]: this class is not key value coding-compliant for the key type.'
와 충돌하지만, 섹션 객체가 type
있다 속성은 문자열의 enum입니다.
왜 술어 대신'.filter'를 사용합니까? – Tj3n
그래, 우리는 할 수있다. 그러나 이런 식으로 처리하는 것이 궁금하다. – Saif