This file contains 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)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context | |
{ | |
if (!object) return; | |
if ([keyPath isEqualToString:@"travelAgencies"]) { | |
NSLog(@"updated to x = %@", [[Model shared].travelAgencies description]); | |
[self.tableView reloadData]; | |
} | |
} |
This file contains 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)fetchTravelAgenciesSampleWithCompletion:(void(^)(NSArray *entities))completion { | |
NSString *resourcePath = @"TravelagencyCollection"; | |
[self scheduleRequestForResource:resourcePath withMode:SODataRequestModeRead withEntity:nil withCompletion:^(NSArray *entities, id<SODataRequestExecution> requestExecution, NSError *error) { | |
if (entities) { | |
completion(entities); | |
This file contains 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
@interface MyViewController () | |
@property (nonatomic, strong) NSString *accountRequestId; | |
@property (nonatomic, strong) NSString *opportunityRequestId; | |
//or | |
@property (nonatomic, strong) NSMutableArray *accountRequests; | |
@end |
This file contains 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
NSDictionary *myTagDictionary = @{@"tag":@"abcd1234"}; | |
SODataRequestParamSingleDefault *request = requestExecution.request; | |
NSString *myTag = request.options[@"tag"]; |
This file contains 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) loadModel | |
{ | |
NSString *accountRequestNotificationIdentifier = @"AccountRequest"; | |
[[NSNotificationCenter defaultCenter] addObserverForName:accountRequestNotificationIdentifier object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { | |
//update the Accounts model | |
}]; |
This file contains 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) requestServerResponse:(id<SODataRequestExecution>)requestExecution | |
{ | |
if ([requestExecution.request.customTag isEqualToString:@"AccountRequest"]) { | |
[[NSNotificationCenter defaultCenter] postNotificationName:@"AccountRequest" object:requestExecution]; | |
} | |
} |
This file contains 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) requestServerResponse:(id<SODataRequestExecution>)requestExecution | |
{ | |
id<SODataRequestExecution>requestExecution = note.object; | |
id<SODataResponse> response = requestExecution.response; | |
id<SODataResponseSingle> respSingle = (id<SODataResponseSingle>) response; | |
id<SODataPayload> p = respSingle.payload; | |
SODataEntitySetDefault *entities = (id<SODataEntitySet>)p; | |
if ([requestExecution.request.customTag isEqualToString:@"AccountRequest"]) { |
This file contains 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)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
if ([[segue identifier] isEqualToString:@"ReturnInputFromAdd"]) { | |
self.properties = [NSMutableArray array]; | |
prop = [[SODataPropertyDefault alloc] initWithName:@"NAME"]; | |
prop.value = self.nameInput.text; | |
[self.properties addObject:prop]; | |
… | |
prop = [[SODataPropertyDefault alloc] initWithName:@"URL"]; | |
prop.value = self.urlInput.text; |
This file contains 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)fetchTravelAgenciesSampleWithCompletion:(void(^)(NSArray *entities))completion { | |
NSString *resourcePath = @"TravelagencyCollection"; | |
SODataRequestParamSingleDefault *myRequest = [[SODataRequestParamSingleDefault alloc] initWithMode:mode resourcePath:resourcePath]; | |
myRequest.payload = entity ? entity : nil; | |
[self scheduleRequest:myRequest completionHandler:^(NSArray *entities, id<SODataRequestExecution> requestExecution, NSError *error) { | |
if (entities) { | |
completion(entities); |