我遇到了UISearchBar的textDidChange委托方法的一个非常奇怪的行为。这是我的代码
cdr
我在委托方法中为searchBar做了一个po,我收到了以下消息
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
searchText = [searchText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (![searchText isEqualToString:@""]) {
[self searchedWithText:searchText]; // I am using this method to fetch my search results from coredata
[searchBar becomeFirstResponder]; // For making the search field active
}
}
-(void)searchedWithText:(NSString *)searchText {
// In this method the type of searchText is shown as NSTaggedPointerString and the value is nil
}
我的问题是searchWithText方法中的searchText参数是nil。所以coredata的结果是零。我在这做错了什么?提前致谢