我在使用谓词过滤数组时遇到问题。我的代码是这个:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSError *error;
NSFileManager *fm = [NSFileManager defaultManager];
NSString *filename=[NSString stringWithFormat:@"%@/%lld-%@.jpg",[paths objectAtIndex:0],[TRIP surrogateKey], ms];
NSArray *dirContents = [fm contentsOfDirectoryAtPath:[paths objectAtIndex:0] error:&error];
NSPredicate *fltr = [NSPredicate predicateWithFormat:@"SELF beginsWith %lld-%@",[TRIP surrogateKey], ms];
NSArray *registros=[dirContents filteredArrayUsingPredicate:fltr];
在调试会话中,我发现我在执行代码的最后一行时遇到问题(NSArray *registros=[dirContents filteredArrayUsingPredicate:fltr]),它给了我以下错误:
-[__NSCFString objCType]: unrecognized selector sent to instance 0x7e67200 2013-02-01 16:37:59.132 GastosApp[4462:11303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objCType]: unrecognized selector sent to instance 0x7e67200'
在调试部分,我看到内存 0x7e67200 被声明的 ms 变量占用:
NSMutableString *ms = [[NSMutableString new] autorelease];
有没有人看到任何错误?
谢谢并恭祝安康