UISearchBar の textDidChange デリゲート メソッドの非常に奇妙な動作に直面しました。これが私のコードです
- (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
}
デリゲート メソッドで searchBar の po を実行したところ、以下のメッセージが表示されました
(lldb) po searchBar
error: warning: couldn't get cmd pointer (substituting NULL): extracting data from value failed
Couldn't materialize: couldn't get the value of variable searchBar: variable not available
Errored out in Execute, couldn't PrepareToExecuteJITExpression
私の問題は、searchedWithText メソッドの searchText パラメータが nil であることです。したがって、coredata の結果は nil です。ここで何が間違っていますか?前もって感謝します