This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Sample
Oleg S edited this page Aug 14, 2014
·
2 revisions
###1. Implement DrupalEntity:
In order to implement drupal entity you just have to extend DrupalEntity
, declare properties and implement following methods:
#####path this method should return relative path to entity on the server:
- (NSString *)path
{
return [NSString stringWithFormat:@"node/%@", self.nodeId];
}
#####requestGETParams this method should return get parameters:
- (NSDictionary *)requestGETParams
{
return @{@"page": self.page}; // Path will be http://myserver.com/?page=10 if self.page value is 10
}
###2. Set server url
Set base url of server before first action with DrupalEntity
object:
[DrupalAPIManager sharedDrupalAPIManager].baseURL = [NSURL URLWithString:@"http://myserver.com"];
####3. Instantiate DrupalEntity
BlogPage *bp = [BlogPage new];
bp.page = @(page);
[bp pullFromServer:nil];
###4. Using completion block
Completion block is defined as: typedef void (^EntityActionHandler)(id result);
. If response was gotten and deserialized result is an DrupalEntity
object otherwise nil
.
[bp pullFromServer:^(id result) {
if (!result) {
// Something went wrong, object was not pulled from server
} else {
// Do something with object
}
}];