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
[SVProgressHUD show]; | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { | |
for(id object in objects) { | |
// CPU heavy code | |
dispatch_async(dispatch_get_main_queue(), ^ { | |
[SVProgressHUD showProgress:x]; | |
}); | |
} |
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
rescue_from Exception, :with => :mail_exception | |
def mail_exception(exception) | |
mail = Mail.new do | |
from 'Rescuer (domain.com) <rescuer@domain.com>' | |
to 'user@domain.com' | |
subject exception.inspect | |
body exception.backtrace[0..10].join("\n") | |
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
- (void)queryDidReceiveNotification:(NSNotification *)notification { | |
NSArray *results = [self.metadataQuery results]; | |
for(NSMetadataItem *item in results) { | |
NSString *filename = [item valueForAttribute:NSMetadataItemDisplayNameKey]; | |
NSNumber *filesize = [item valueForAttribute:NSMetadataItemFSSizeKey]; | |
NSDate *updated = [item valueForAttribute:NSMetadataItemFSContentChangeDateKey]; | |
NSLog(@"%@ (%@ bytes, updated %@)", filename, filesize, updated); | |
} | |
} |
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
self.metadataQuery = [[NSMetadataQuery alloc] init]; | |
[metadataQuery setPredicate:[NSPredicate predicateWithFormat:@"%K LIKE '*'", NSMetadataItemFSNameKey]]; |
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
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(queryDidReceiveNotification:) | |
name:NSMetadataQueryDidUpdateNotification | |
object:self.metadataQuery]; |
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
self.view.layer.anchorPoint = CGPointMake(0.50, 1.0); | |
CAKeyframeAnimation *bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; | |
bounceAnimation.values = [NSArray arrayWithObjects: | |
[NSNumber numberWithFloat:0.05], | |
[NSNumber numberWithFloat:1.08], | |
[NSNumber numberWithFloat:0.92], | |
[NSNumber numberWithFloat:1.0], | |
nil]; |
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)scrollViewDidScroll:(UIScrollView *)scrollView { | |
CGFloat maxY = scrollView.contentSize.height+scrollView.contentInset.bottom; | |
CGFloat botY = scrollView.contentOffset.y+scrollView.frame.size.height; | |
NSLog(@"y = %f, maxY = %f", botY, maxY); | |
if(botY >= maxY) { | |
// load next page | |
} | |
} |
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)viewDidLoad { | |
self.currentPage = 0; | |
self.dataSource = [[NSMutableArray alloc] init]; | |
} | |
- (void)fetchData { | |
[[SVHTTPClient sharedClient] GET:@"https://api.github.com/users/AndrewGertig/watched" | |
parameters:[NSDictionary dictionaryWithValue:[NSNumber numberWithInt:self.currentPage] forKey:@"page"] | |
completion:^(id response, NSError *error) { | |
[self.dataSource addObjectsFromArray:response]; |
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 Class () | |
@property (nonatomic, readonly) NSDateFormatter *dateFormatter; | |
@end | |
@implementation Class | |
@synthesize dateFormatter; |
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
[SVHTTPRequest GET:@"http://github.com/api/v2/json/repos/show/samvermette/SVHTTPRequest" | |
parameters:nil | |
completion:^(id response, NSError *error) { | |
NSNumber *watchers = [[response valueForKey:@"repository"] valueForKey:@"watchers"]; | |
NSLog(@"SVHTTPRequest has %@ watchers", watchers); | |
}]; |
NewerOlder