以下方法顯示警告,但應用程序按預期執行。請你能檢查代碼並告訴我哪裏出了錯?只有當這個重要的應用程序,如果警告是沒有危險的應用程序,然後告訴我,如果我可以讓這個,因爲它是...謝謝方法定義警告
警告是:Incompatible pointer types assigning to 'NSMutableArray *' from 'NSArray *'
在方法定義。
-(void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope {
self.searchResults = [[self.fetchedResultsController fetchedObjects] filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings)
{
ToDoItem * item = evaluatedObject;
NSString* name = item.todoName;
//searchText having length < 3 should not be considered
if (!!searchText && [searchText length] < 3) {
return YES;
}
if ([scope isEqualToString:@"All"] || [name isEqualToString:scope]) {
return ([name rangeOfString:searchText].location != NSNotFound);
}
return NO; //if nothing matches
}]];
}
searchResults是一個NSMutableArray嗎? – John
什麼是'!! searchText' ...? – nhgrif
它是來自搜索欄控制器的文本 – mvasco