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 *)appNameAndVersionNumberDisplayString { | |
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; | |
NSString *majorVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"]; | |
NSString *minorVersion = [infoDictionary objectForKey:@"CFBundleVersion"]; | |
return [NSString stringWithFormat:@"%@ (%@)", | |
majorVersion, minorVersion]; | |
} |
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
// Register notification when the keyboard will be show | |
[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillShow:) | |
name:UIKeyboardWillShowNotification | |
object:nil]; | |
// Register notification when the keyboard will be hide | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillHide:) | |
name:UIKeyboardWillHideNotification |
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
#!/bin/bash | |
for i in {5..0} | |
do | |
if [ $i -eq 0 ] | |
then | |
echo '2016 hooray~~...' | |
else | |
echo $i '..' | |
fi | |
sleep 1; |
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
// setup code to draw / display avatar | |
UIView *avatarView = [[UIView alloc] init]; | |
avatarView.frame = CGRectMake(20, 50, 280, 100); | |
avatarView.layer.borderColor = [UIColor redColor].CGColor; | |
avatarView.layer.borderWidth = 3.0f; | |
[self.view addSubview:avatarView]; | |
// do additional loading for avatars | |
UIButton *avatarButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; | |
// the last two values control the size of the button |
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
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; | |
[userInfo setObject:@"You are not authenticated." forKey:NSLocalizedDescriptionKey]; | |
NSError *error = [NSError errorWithDomain:@"mydomain" code:0 userInfo:userInfo]; |
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
[PHPhotoLibrary sharedPhotoLibrary] performChanges: ^{ | |
[PHAssetChangeRequest deleteAssets: @[phAssetsInArray.firstObject]]; | |
} completionHandler:^(BOOL success, NSError *error) { | |
if(error) { | |
// user cancel deleting operation can cause error too. | |
} | |
}]; |
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
dispatch_async(dispatch_queue_create("com.marku", DISPATCH_QUEUE_PRIORITY_DEFAULT), ^{ | |
//code | |
}); |
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*) tempFolderPath { | |
if(_tempFolderPath == nil) { | |
NSError* err; | |
_tempFolderPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]]; | |
[[NSFileManager defaultManager] createDirectoryAtPath:_tempFolderPath withIntermediateDirectories:YES attributes:nil error:&err]; | |
NSLog(@"temporary folder created at %@", _tempFolderPath); | |
if(err) { | |
NSLog(@"error when creating temporary folder. %@", err); | |
// TODO better error handler | |
} |
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) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat; | |
{ | |
// #import <QuartzCore/QuartzCore.h> | |
CABasicAnimation* rotationAnimation; | |
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; | |
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ]; | |
rotationAnimation.duration = duration; | |
rotationAnimation.cumulative = YES; | |
rotationAnimation.repeatCount = repeat; |
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.statusView = (StatusView*) ([[UINib nibWithNibName:@"StatusView" bundle:nil] | |
instantiateWithOwner:nil options:nil][0]); |