Created
November 5, 2014 21:27
-
-
Save sstadelman/b5a4e90ccb32a707f04f to your computer and use it in GitHub Desktop.
[online] filtering entities when $filter not supported by back end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(void)fetchContactsWithCompletion:(void(^)(NSArray *entities))completion { | |
| NSString *resourcePath = @"ContactCollection; | |
| [self scheduleRequestForResource:resourcePath withMode:SODataRequestModeRead withEntity:nil withCompletion:^(NSArray *entities, id<SODataRequestExecution> requestExecution, NSError *error) { | |
| if (entities) { | |
| NSMutableArray *completeEntities = [[NSMutableArray alloc] init]; | |
| [entities enumerateObjectsUsingBlock:^(id<SODataEntity> obj, NSUInteger idx, BOOL *stop) { | |
| NSDictionary *properties = (id<SODataEntity>)obj.properties; | |
| NSString *company = (NSString *)[(id<SODataProperty>)properties[@"company"] value]; | |
| NSString *function = (NSString *)[(id<SODataProperty>)properties[@"function"] value]; | |
| if (company.length > 0 && function.length > 0) { | |
| [completeEntities addObject:obj]; | |
| } | |
| }]; | |
| completion(completeEntities); | |
| } else { | |
| NSLog(@"did not get any entities, with error: %@", error); | |
| } | |
| }]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment