Skip to content

Instantly share code, notes, and snippets.

@jkhowland
Last active August 29, 2015 14:05
Show Gist options
  • Save jkhowland/135865ad41e9afe86898 to your computer and use it in GitHub Desktop.
Save jkhowland/135865ad41e9afe86898 to your computer and use it in GitHub Desktop.
GitReference - Data Methods - Objective-C
static CGFloat margin = 15;
static NSString * const Command = @"command";
static NSString * const Reference = @"reference";
- (NSArray *)gitCommands {
return @[@{Command: @"git status", Reference: @": shows changed files"},
@{Command: @"git diff", Reference: @": shows actual changes"},
@{Command: @"git add .", Reference: @": adds changed files to the commit"},
@{Command: @"git commit -m \"notes\"", Reference: @": commits the changes"},
@{Command: @"git push origin _branch_", Reference: @": pushes commits to branch named _branch_"},
@{Command: @"git log", Reference: @": displays progress log"},
@{Command: @"git comment --amend", Reference: @": re-enter last commit message"}
];
}
- (CGFloat)heightOfReferenceString:(NSString *)reference {
CGRect bounding = [reference boundingRectWithSize:CGSizeMake(self.view.frame.size.width - 2 * margin, 0)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}
context:nil];
return bounding.size.height;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment