Skip to content

Instantly share code, notes, and snippets.

View timd's full-sized avatar
💭
Typing all the right things, not necessarily in the right order

Tim Duckett timd

💭
Typing all the right things, not necessarily in the right order
View GitHub Profile
@timd
timd / gist:1226528
Created September 19, 2011 13:47
Extended error dump for Core Data errors
if(![managedObjectContext save:&error]) {
NSLog(@"Failed to save to data store: %@", [error localizedDescription]);
NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey];
if(detailedErrors != nil && [detailedErrors count] > 0) {
for(NSError* detailedError in detailedErrors) {
NSLog(@" DetailedError: %@", [detailedError userInfo]);
}
}
else {
NSLog(@" %@", [error userInfo]);
@timd
timd / gist:1835386
Created February 15, 2012 12:31
didSwipeLeftInCell:
-(IBAction)didSwipeLeftInCell:(id)sender {
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView animateWithDuration:1.0 animations:^{
[_topView setFrame:CGRectMake(-10, 0, 320, 80)];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.15 animations:^{
[_topView setFrame:CGRectMake(0, 0, 320, 80)];
}];
}];
}
@timd
timd / didSwipeLeftInCell.m
Created February 15, 2012 12:39
didSwipeLeftInCell:
-(IBAction)didSwipeLeftInCell:(id)sender {
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView animateWithDuration:1.0 animations:^{
[_topView setFrame:CGRectMake(-10, 0, 320, 80)];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.15 animations:^{
[_topView setFrame:CGRectMake(0, 0, 320, 80)];
}];
}];
}
@timd
timd / swipeCell.m
Created February 15, 2012 12:41
initWithStyle:reuseidentifier:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
// Create the top view
_topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, 80)];
[_topView setBackgroundColor:[UIColor whiteColor]];
@timd
timd / scrollViewDidEndDragging.m
Created February 16, 2012 10:02
scrollViewDidEndDragging:willDecelerate:
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
CGFloat contentOffsetY = scrollView.contentOffset.y;
if (contentOffsetY < -60.0) {
[self displayActivitySpinner];
}
}
@timd
timd / gist:2317906
Created April 6, 2012 07:24
Simulator-safe method for using the hardware camera on iOS Simulators
-(void)takeSimulatorSafePhotoWithPopoverFrame:(GCRect)popoverFrame {
// Prerequisites:
//
// Class requires two properties to be defined:
//
// @property (nonatomic, strong) UIImagePickerController *imagePicker;
// @property (nonatomic) BOOL usingPopover;
// Load the imagePicker
@timd
timd / .gitignore
Created August 2, 2012 07:34 — forked from Abizern/.gitignore
Global git ignore file
# Mac OS X
*.DS_Store
# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
@timd
timd / ios-font-list
Created August 3, 2012 10:17
List of onboard iOS fonts in iOS5.1 / Xcode 4.4
Thonburi
"Thonburi-Bold",
Thonburi
Snell Roundhand
"SnellRoundhand-Bold",
"SnellRoundhand-Black",
SnellRoundhand
Academy Engraved LET
@timd
timd / gist:3293993
Created August 8, 2012 10:12
Adding UIGestureRecognizer to UIWebView
Add gesture recognizer to UIWebView:
UITapGestureRecognizer *tapCatcher = [[UITapGestureRecognizer alloc] init];
[tapCatcher setNumberOfTapsRequired:1];
[tapCatcher setNumberOfTouchesRequired:1];
[tapCatcher setDelegate:self];
[tapCatcher addTarget:self action:@selector(didTapOnView)];
[self.webView addGestureRecognizer:tapCatcher];
@timd
timd / gist:3498466
Created August 28, 2012 14:24
Provide build number for source code
# build data file that is included in the source
# so we can automatically report Git repo information
# in the application.
cd ${PROJECT_DIR}
gitDataFile="gitDataAutoGenerated.h"
buildDate=`date "+%F %H:%M:%S"`
currentBranch=`git rev-parse --abbrev-ref HEAD`
lastCommitHash=`git log --pretty=format:"%h" -1`
lastCommitDate=`git log --pretty=format:"%ad" --date=short -1`