I have 2 lacs of data in an NSArray. I have to search in that NSArray. Presently I’m splitting this NSArray and searching them in separate threads else it would take long time. I’m able to search the datas but cannot combine it to another NSArray.
For example, if I search for “a” I get all results with “a” in all the threads. But these threads result cannot be combined to a single NSArray.
The code I used is as follows
NSArray *subArray = [mArrayOrginalData subarrayWithRange:range];
SearchOperation *anOperation = [[SearchOperation alloc]init];
[anOperation setSearchData:[subArray mutableCopy]];
[anOperation setPattern:txtFieldPattern.text];
[anOperation setTarget:self];
[anOperation setAction:@selector(searchResultHandler:)];
[searchQueue addOperation:anOperation];
The code for retrieving data is another class(NSOperation) the code is as given below
@implementation SearchOperation
- (void) main{
NSLog(@"%s",__PRETTY_FUNCTION__);
NSMutableArray* mArrayTmp = [Search searchByPattern:self.pattern inputArray:searchData];
NSLog(@"Sub result count : %d",[mArrayTmp count]);
[target performSelector:action withObject:mArrayTmp];
}
@@end
Your code looks good from what I can tell.
Your observing target would have something like this…