0

I have faced a very strange behavior for textDidChange delegate method of UISearchBar. Here is my code

- (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

}

I did a po for searchBar in the delegate method and I got the below message

(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

My issue is the searchText parameter in my searchedWithText method is nil. So the results from coredata is nil. What am I doing wrong here? Thanks in advance

Arun
  • 1,391
  • 1
  • 10
  • 29
  • What line of the delegate method are you on? Can you try it again when you are on the `becomeFirstResponder` method. Also, can you NSLog the searchBar instead? – Lou Franco Feb 01 '16 at 14:47
  • When I am on the line from where I am calling my other method. I gave NSLog for the searchBar and I got proper value ; layer = > – Arun Feb 01 '16 at 14:50
  • Make sure that you are attached to Debug version of your application, and compiler optimizations are turned off for debug. – Borys Verebskyi Feb 01 '16 at 15:21
  • Is there a problem with the execution of the app or just the po? I haven't found LLDB to be perfect -- it might not be a problem – Lou Franco Feb 01 '16 at 15:26
  • Actually my issue is not the search bar becoming nil. The issue is search key passed to the method is nil – Arun Feb 01 '16 at 17:06

0 Answers0