简体   繁体   中英

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

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:NSCaseInsensitiveSearch];

  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM