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
// Text field delegates | |
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { | |
if ([[textField text] length] + [string length] - range.length > MAX_LENGTH) { | |
return NO; | |
} else { | |
return YES; | |
} | |
} |
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
$ git branch experimental | |
$ git branch | |
$ git checkout experimental | |
(edit file) | |
$ git commit -a | |
$ git checkout master | |
(edit file) | |
$ git commit -a | |
$ git merge experimental | |
$ git diff |
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
defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ORGANIZATIONNAME="YourNameHere";}' |
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
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray array]]; | |
[segmentedControl setMomentary:YES]; | |
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"191-Up.png"] atIndex:0 animated:NO]; | |
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"191-Down.png"] atIndex:1 animated:NO]; | |
segmentedControl.autoresizingMask = UIViewAutoresizingNone; | |
segmentedControl.frame = CGRectMake(0.0f, 0.0f, 90.0f, 30.0f); | |
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; | |
[segmentedControl addTarget:self action:@selector(pagingAction:) forControlEvents:UIControlEventValueChanged]; | |
UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl]; |
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
#define FONT_SIZE 14.0f | |
#define CELL_CONTENT_WIDTH 320.0f | |
#define CELL_CONTENT_MARGIN 10.0f | |
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; | |
{ | |
NSString *text = [items objectAtIndex:[indexPath row]]; | |
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f); | |
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap]; | |
CGFloat height = MAX(size.height, 44.0f); |
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
- (NSString *)getFirstImage:(NSString *)html { | |
NSString *tempText = [[NSString alloc]initWithFormat:@""]; | |
NSScanner *pageScanner = [NSScanner scannerWithString:html]; | |
[pageScanner setCaseSensitive:NO]; | |
[pageScanner setCharactersToBeSkipped:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; | |
[pageScanner scanUpToString:@"<img " intoString:nil]; | |
[pageScanner scanString:@"<img " intoString:nil]; | |
[pageScanner scanUpToString:@"src=\"" intoString:nil]; | |
[pageScanner scanString:@"src=\"" intoString:nil]; | |
[pageScanner scanUpToString:@"\"" intoString:&tempText]; |
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
#import <Twitter/Twitter.h> | |
- (IBAction)tweetButtonTapped:(id)sender | |
{ | |
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init]; | |
[twitter addURL:[NSURL URLWithString:@"http://www.sumardi.net"]; | |
[twitter setInitialText:@"Checkout my blog"]; | |
[self presentModalViewController:twitter animated:YES]; |
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
- (id)readPlist:(NSString *)fileName { | |
NSData *plistData; | |
NSString *error; | |
NSPropertyListFormat format; | |
id plist; | |
NSString *localizedPath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"plist"]; | |
plistData = [NSData dataWithContentsOfFile:localizedPath]; | |
plist = [NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error]; |
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
#ifdef DEBUG | |
# define WMLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); | |
#else | |
# define WMLog(...) | |
#endif |
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 endEditing:YES]; | |
// .... |