Skip to content

Instantly share code, notes, and snippets.

@SPopenko
Created September 25, 2012 13:17
Show Gist options
  • Save SPopenko/3781765 to your computer and use it in GitHub Desktop.
Save SPopenko/3781765 to your computer and use it in GitHub Desktop.
Instructions for devs to create their own ActionBar Implemntation
[SZLikeUtils isLiked:entity
success:^(BOOL isLiked){
[self setEntityLiked: isLiked]; //update button icon & internal state
}
failure:^(NSError *error){
NSLog(@"Failed detect like: %@", [error localizedDescription]);
[self setEntityLiked: NO]; //update button icon & internal state
}];
[SZCommentUtils showCommentsListWithViewController:parentController entity:entity completion:^(){
[self updateStatistic];
}];
if([self checkIfEntityWasLiked] == NO)
{
[SZLikeUtils likeWithViewController:parentController options:nil entity:entity
success:^(id<SZLike> like){
[self setEntityLiked: YES]; //update button icon & internal state
[self updateStatistic];
}
failure:^(NSError *error) {
NSLog(@"Failed creating like: %@", [error localizedDescription]);
}];
}
else
{
[SZLikeUtils unlike:entity
success:^(id<SZLike> like) {
[self setEntityLiked: NO]; //update button icon & internal state
[weekSelf updateStatistic];
}
failure:^(NSError *error) {
NSLog(@"Failed deleting like: %@", [error localizedDescription]);
}];
}
-(void)setEntity:(id<SocializeEntity>)entity
{
if(entity == nil)
{
[_entity release]; _entity = nil;
return;
}
if(_entity != entity)
{
[_entity release]; _entity = [entity retain];
if([entity isFromServer])
{
[self continueConfiguration];
}
else
{
[SZEntityUtils addEntity:entity success:^(id<SZEntity> serverEntity)
{
[_entity release]; _entity = [serverEntity retain];
[self continueConfiguration];
}
failure:^(NSError *error) {
SZEmitUIError(self, error);
}];
}
}
}
[SZShareUtils showShareDialogWithViewController:parentController entity:entity completion:^(NSArray *shares){
[self updateStatistic];
} cancellation:nil];
[SZUserUtils showUserProfileInViewController:parentController user:nil completion:nil];
-(void) updateStatistic
{
[SZEntityUtils getEntityWithKey:entity.key success:^(id<SZEntity> entity)
{
self.entity = entity;
[self updateCountBobble];
} failure:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment