开发者

iPhone/iPad - Problem with Copy values of NSArray into NSMutableArray?

开发者 https://www.devze.com 2023-02-03 14:34 出处:网络
This code is the search code - (void) searchTableView { NSLog(@\"4\"); NSString *searchText = searchBar.text;

This code is the search code

- (void) searchTableView {
 NSLog(@"4");
 NSString *searchText = searchBar.text;
 NSMutableArray *searchArray = [[NSMutableArray alloc] init];

 for (NSDictionary *dictionary in listOfItems)
 {
  NSArray *array = [dictionary objectForKey:@"Countries"];
  [searchArray addObjectsFromArray:array];
 }

 for (NSString *sTemp in searchArray)
 {
  NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveS开发者_如何学JAVAearch];

  if (titleResultsRange.length > 0)
   [copyListOfItems addObject:sTemp];
 }
 //NSLog(@"Count - %d",[copyListOfItems count]);
 [searchArray release];
 searchArray = nil;
}

I want to implement this type of search in my array but i am getting error in below line.

[searchArray addObjectsFromArray:array]; 

when control comes on this line application shutdown every time can any one help me ?

Thanks


That line will give you an error only if array has nothing in it(nil value).

So check what is the value of array using nslog.

0

精彩评论

暂无评论...
验证码 换一张
取 消