Actually I may have gotten some of it done.
My iPhone VC now just has this:
Code:
- (void)performSearchForString:(NSString *)iSearchString {
self.hideTable = NO;
self.isSearching = YES;
[self.searchDisplayController.searchResultsTableView reloadData];
NSArray *aFilteredArray = [self.currentScopeArray filteredArrayUsingPredicate:self.searchScopePredicate];
self.masterArray = [NSMutableArray arrayWithObjects:[NSNull null], [NSNull null], [NSNull null], [NSNull null], nil];
CMASearchController *searchController = [[CMASearchController alloc]init];
[searchController performSearchWithArray:aFilteredArray andSearchTerm:iSearchString];
[searchController release];
}
and my search class has this:
Code:
- (void)performSearchWithArray:(NSArray *)iArray andSearchTerm:(NSString *)iSearchTerm {
for (NSInteger x = 0; x < iArray.count; x++) {
NSMutableDictionary *aPostBody = [NSMutableDictionary dictionaryWithCapacity:3];
NSDictionary *aScopeDictionary = [iArray objectAtIndex:x];
NSString *aSearchType = [aScopeDictionary objectForKey:@"searchType"];
[aPostBody setObject:iSearchTerm forKey:@"searchTerm"];
[aPostBody setObject:aSearchType forKey:@"searchType"];
ISTServiceRequest *aFormRequest = [ISTServiceRequest post:[[CMAConfiguration sharedConfiguration] endpointForKey:@"search"] body:aPostBody requestDidFinishBlock:^(ISTServiceRequestReceipt *aReceipt) {
if (aReceipt.responseObject && [aReceipt.responseObject isKindOfClass:[NSArray class]]) {
NSArray *aResultsArray = aReceipt.responseObject;
Class aSearchObjectType = nil;
if ([aSearchType isEqualToString:@"GUEST"] || [aSearchType isEqualToString:@"MEMBER"]) {
aSearchObjectType = [CMACustomer class];
} else if ([aSearchType isEqualToString:@"RESERVATION"] || [aSearchType isEqualToString:@"PICKUP"]) {
aSearchObjectType = [CMAReservation class];
}
[self.masterArray replaceObjectAtIndex:aReceipt.tag withObject:[aSearchObjectType objectsFromServerDictionaries:aResultsArray]];
[self stopAnimationAtSection:aReceipt.tag];
}
}];
aFormRequest.tag = x;
}
}
But how can I handle these two lines from the search class that modify attributes in the iPhone vc?
Code:
[self.masterArray replaceObjectAtIndex:aReceipt.tag withObject:[aSearchObjectType objectsFromServerDictionaries:aResultsArray]];
[self stopAnimationAtSection:aReceipt.tag];