2012-02-04 2 views
0

날짜 속성이있는 개체 배열을 정렬하는 조건자를 만들려고합니다. 그러나 술어를 NSLog하려고하면 예외가 발생하고 이상한 오류가 발생합니다.로깅 할 때 매우 이상한 NSPredicate 동작

NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init]; 
[dateFormatter setDateFormat:@"yyyy"]; 
NSDate * minDate = [dateFormatter dateFromString:@"2011"]; 
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date >= %@ ", minDate]; 
NSLog(predicate); 
다음

오류입니다 :

2012-02-04 12:45:58.400 MyApp[42746:17303] -[NSComparisonPredicate length]: unrecognized selector sent to instance 0x9359000 

그래서, 내가 그것을 어떻게 이런 일이 왜 문제를 해결할 수있다

여기

코드인가?

+0

당신이 술어를 적용하려는 속성의 정확한 유형은 무엇입니까? – Costique

+0

NSDate. 그러나, 나는 심지어 내가 실제로 술어를 사용하는 곳에 도착하지도 않는다. –

+0

NSDates를 이와 같은 술어와 비교할 수 있을지 모르겠다. 그리고 네, 그런 식으로 NSLog()를 사용할 수 없습니다. – Costique

답변

2

시도 : NSLog(@"%@", predicate)

NSLog는 형식 문자열로 작동하는있는 NSString을 기대하고있다. 형식 문자열에있는 형식 지정자의 수는 따라야하는 인수의 수를 지정합니다. doc에서

:

NSLog
Logs an error message to the Apple System Log facility.

void NSLog (
    NSString *format, 
    ... 
); 

Discussion
Simply calls NSLogv, passing it a variable number of arguments.

관련 문제