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
NSStringEncoding usedEncoding; | |
NSError * err; | |
NSString * k = [NSString stringWithContentsOfFile:path usedEncoding:&usedEncoding error:&err]; | |
if (err) { | |
NSStringEncoding big5 = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingBig5_HKSCS_1999); | |
k = [NSString stringWithContentsOfFile:path encoding:big5 error:&err]; | |
} |
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
/* Using popover to present service list */ | |
UIPopoverController * popover = [[UIPopoverController alloc] initWithContentViewController:aController]; | |
popover.popoverContentSize = CGSizeMake(320.0, 400.0); | |
popover.delegate = self; | |
[aController release]; | |
[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny 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
# IDEA Ignores # | |
################ | |
*.iml | |
*.ipr | |
*.iws | |
.idea/ | |
out/ | |
local.properties | |
# Generic Android ignores # |
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
/* | |
* Check http://stackoverflow.com/questions/2777438/how-to-tell-if-uiviewcontrollers-view-is-visible | |
* to see the discussions. | |
* If the container is a UINavigationController, | |
* we can use the visibleViewController property | |
* to check the visibility. | |
*/ | |
navigationController visibleViewController == self | |
/* Or, we can add a category to UIViewController |
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
/* | |
* Excerpt from : | |
* http://rosettacode.org/wiki/Walk_a_directory/Recursively#Objective-C | |
*/ | |
NSString *dir = NSHomeDirectory(); | |
NSDirectoryEnumerator *de = [[NSFileManager defaultManager] enumeratorAtPath:dir]; | |
NSString *file; | |
while ((file = [de nextObject])) | |
if ([[file pathExtension] isEqualToString:@"mp3"]) |
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
TODAY=`date +%Y%m%d` | |
YESTERDAY=`TZ=GMT+24 date +%Y%m%d` | |
echo $TODAY | |
echo $YESTERDAY |
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
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ " | |
export CLICOLOR=1 | |
export LSCOLORS=dxfxcxdxbxegedabagacad |
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
UIImage *icon = [[UIImage imageNamed:@"image_name.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; | |
cell.imageView.image = icon; | |
cell.imageView.tintColor = [UIColor colorWithRed:98/255.0f green:126/255.0f blue:255/255.0f alpha:1.0]; |
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
// Auto layout center element to super view | |
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]]; | |
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]]; | |
//Auto layout | |
//指定自己width height同高 | |
[self addConstraint:[NSLayoutConstraint constraintWithItem:self |
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
# Switch xcrun to leverage Xcode 7 | |
# Note: This won't be needed once Xcode 7 is released | |
# and becomes the primary Xcode in use. | |
export DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer/ | |
# Export Archive | |
xcrun xcodebuild -exportArchive -exportOptionsPlist exportPlist.plist -archivePath /path/to/app.xcarchive -exportPath /path/to/app.ipa |