Skip to content

Instantly share code, notes, and snippets.

View kenshin03's full-sized avatar

Kenny Tang kenshin03

View GitHub Profile
#import "PSHCoverFeedViewController.h"
#import "PSHFacebookDataService.h"
#import "PSHCoverFeedPageViewController.h"
#import "PSHMenuViewController.h"
#import "PSHMessagingViewController.h"
#import "FeedItem.h"
#import "ItemSource.h"
@interface PSHCoverFeedViewController ()<UIPageViewControllerDataSource, PSHMenuViewControllerDelegate, PSHCoverFeedPageViewControllerDelegate, PSHMessagingViewControllerDelegate>
@kenshin03
kenshin03 / gist:7963568
Created December 14, 2013 19:15
iOS Objective-C Coding Standard

View management

Do not use interface builder for production code; instead, override -loadView. Use autolayout when possible.

Comments

/*!
 * Method comment.
@kenshin03
kenshin03 / gist:6303582
Last active April 21, 2019 06:25
Heartbeat like vibration with private API AudioServicesPlaySystemSoundWithVibration
NSMutableDictionary* pulsePatternsDict = [@{} mutableCopy];
NSMutableArray* pulsePatternsArray = [@[] mutableCopy];
// beat for 100 times
for (NSInteger i=0; i<100; i++){
[pulsePatternsArray addObject:@(YES)]; // vibrate for 100ms
[pulsePatternsArray addObject:@(100)];
[pulsePatternsArray addObject:@(NO)]; //stop for 1200ms * 0.3
[pulsePatternsArray addObject:@(1200*0.3)];
@kenshin03
kenshin03 / gist:5602049
Created May 17, 2013 21:21
pull to dismiss
#pragma mark - UITableViewDelegate delegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.contentOffset.y < -160.0f){
dispatch_once(&pullToDismissLock, ^{
CGRect destFrame = self.notificationsTableView.frame;
destFrame.origin.y = destFrame.size.height;
[UIView animateWithDuration:0.4f delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^{
@kenshin03
kenshin03 / gist:5602000
Created May 17, 2013 21:12
Fetch notifications
- (void) fetchNotifications:(FetchNotificationsSuccess)fetchNotificationsSuccess {
InitAccountSuccessBlock successBlock = ^{
NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/notifications"];
SLRequest * request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:url parameters:@{@"include_read":@"true"}];
DDLogVerbose(@"request.URL: %@", request.URL);
request.account = self.facebookAccount;
@kenshin03
kenshin03 / gist:5551676
Created May 10, 2013 00:38
menuGestureRecognizerAction
- (void) menuGestureRecognizerAction:(PSHMenuGestureRecognizer*)recognizer {
if (recognizer.state == UIGestureRecognizerStateBegan){
// began moving
} else if (recognizer.state == UIGestureRecognizerStateChanged){
CGRect launcherButtonImageViewFrame = [self.view convertRect:self.launcherButtonImageView.frame fromView:self.launcherButtonImageView.superview];
@kenshin03
kenshin03 / gist:5551666
Created May 10, 2013 00:36
PSHMenuGestureRecognizer
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.view];
UIView * menuView = [self.view viewWithTag:kPSHMenuViewControllerMenuButtonViewTag];
if (CGRectContainsPoint(menuView.frame, touchPoint)){
[self setState:UIGestureRecognizerStateBegan];
self.menuViewBeingMoved = menuView;
}else{
@kenshin03
kenshin03 / gist:5551611
Created May 10, 2013 00:25
animate menu expand
- (void) animateExpandMenuButtons {
self.launcherButtonView.hidden = NO;
self.notificationsButtonView.hidden = NO;
self.messengerButtonView.hidden = NO;
self.launcherButtonLabel.hidden = NO;
self.notificationsButtonLabel.hidden = NO;
self.messengerButtonLabel.hidden = NO;
[UIView animateWithDuration:0.2f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{
@kenshin03
kenshin03 / gist:5551606
Created May 10, 2013 00:23
hide menu buttons
/*
// expanded
self.expandedMenuButtonFrame = CGRectMake(120.0f, 458.0f, 90.0f, 90.0f);
self.expandedMessengerButtonFrame = CGRectMake(10.0f, 429.0f, 72.0f, 110.0f);
self.expandedLauncherButtonFrame = CGRectMake(124.0f, 306.0f, 72.0f, 110.0f);
self.expandedNotificationsButtonFrame = CGRectMake(240.0f, 429.0f, 72.0f, 110.0f);
// collapsed
self.collapsedButtonsFrame = CGRectMake(124.0f, 430.0f, 72.0f, 110.0f);
*/
@kenshin03
kenshin03 / gist:5497062
Created May 1, 2013 18:11
output from ACAccountStore accountTypeWithAccountTypeIdentifier:
2013-05-01 10:06:06.036 Home[87441:1c03] granted: 1
2013-05-01 10:06:06.040 Home[87441:1303] accounts: (
"type:com.apple.facebook\nidentifier: F5D9D131-7A36-4FFD-A187-A09B07DDF86F\naccountDescription: Facebook\nusername: [email protected]\nobjectID: x-coredata://92135DD2-592B-4F75-87FF-9965AE7E3B13/Account/p2\nenabledDataclasses: {(\n \"com.apple.Dataclass.Contacts\",\n \"com.apple.Dataclass.Calendars\"\n)}\nenableAndSyncableDataclasses: {(\n)}\nproperties: {\n fullname = \"Kenny Tang\";\n uid = 572733568;\n}\nparentAccount: (null)\nowningBundleID:(null)"
)