title: How to search data from sqlite with UISearchBar in iOS?
body: <p>I would like to ask a question.
  Now i am training in iOS with UISearchBar , TableView and Sqlite.
  I have sqlite database and i want to search data from that sqlite database and then i want to show that search data in tableView.
  I already select data into NSMutableArray named myArray in ViewDidLoad Event like following code.</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
  
      MyInfo *myInfo = [[MyInfo alloc] init];
      myArray = [myInfo getInitialData]; // myArray is my NSMutableArray's variable name and getData From getInitialData Method.
  
      [tableData addObjectsFromArray:myArray]; // tableData is my next NSMutableArray's variable name that i want to show search data in tableView.
  }
  </code></pre>
  
  <p>like that.I added data from myArray into tableData.
  and then i write some of code in UISearchBar's textDidChange Events following like that.</p>
  
  <pre><code>- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
  {
      if([searchText isEqualToString:@""] || searchText==nil)
      {
          [myTableView reloadData];
          return;
      }
  
      NSInteger counter = 0;
      for(NSString *nameMe in myArray)
      {
          NSRange r = [[nameMe lowercaseString] rangeOfString:[searchText lowercaseString]];
          if(r.location != NSNotFound)
          {
              if(r.location== 0)//that is we are checking only the start of the names.
              {
                  [tableData addObject:nameMe];
              }
          }
  
          counter++;
      }
      [myTableView reloadData];
  }
  </code></pre>
  
  <p>But i can't search data from database.There was error occurring.
  I think i am wrong in my search code.
  My column name is "name" that i want to search from database.
  However i don't know how to search data with UISearchBar.
  If my codes are wrong,please advice me how to search data from sqlite.
  I am just beginner in iOS , please help me.</p>
  
  <p>Best Regards,</p>