navigationController?.toolbarHidden = false
// let hiddenはnil判定かつOptionalの開示された変数なのでwhereがないと条件が真になってしまう
if let hidden = navigationController?.toolbarHidden where isbar {
println(hidden)
}
else {
println(hidden)
}
let a: String?
let b: String!
let c: String
a = nil //OK
b = nil //OK
c = nil //NG
var evens = [Int]()
for i in 1...10 {
if i % 2 == 0 {
evens.append(i)
}
}
var evenSum = 0
for i in evens {
Objective-C
+ (UIViewController*)viewControllerForStoryboardName:(NSString*)storyboardName class:(id)class
{
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
NSString* className = nil;
if ([class isKindOfClass:[NSString class]])
This file contains hidden or 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
Xcodeの | |
Edit -> Convert -> To Latest Swift Syntax... | |
である程度やってくれる |
This file contains hidden or 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
UIViewの継承クラス | |
- (void)drawRect:(CGRect)rect { | |
// Drawing code | |
UIBezierPath *path = [UIBezierPath bezierPath]; | |
// 線の色を設定 | |
[[UIColor colorWithRed:151.0/255.0 green:151.0/255.0 blue:151.0/255.0 alpha:1.0] set]; | |
// 線の太さを設定 | |
[path setLineWidth:1.0f]; | |
// 点線のパターンを設定 | |
// 5px線を描き、7px空白にする |
This file contains hidden or 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
NSDateFormatter* formatter = [NSDateFormatter new]; | |
formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; | |
formatter.timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; | |
NSDate* date = [formatter dateFromString:@"2013-10-04T05:16:29.000Z"]; |
This file contains hidden or 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
for (UIView *view in [self.view subviews]) { | |
[view removeFromSuperview]; | |
} | |
と | |
[[self.view subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)]; | |
は同じ意味になる |
This file contains hidden or 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 reset --hard ORIG_HEAD | |
git reset --hard $commit_id で現在のブランチの指す先を差し替えられますから、 git log --graph --oneline --decorate などでコミットログを表示して マージ前の状態に相当するコミット(例えばID badcafe のコミット)を探して git reset --hard badcafe とすればマージ前の状態に巻き戻すことができます。 でもこれはちょっと面倒です。 | |
実は git merge のような「危険」な(= 現在のブランチの内容を大幅に変える可能性のある)コマンドの場合、 実行前の状態を ORIG_HEAD という名前で参照できるようになっています。 つまり、わざわざコミットログを確認しなくても以下のコマンドで マージ前の状態に巻き戻すことができます: |
This file contains hidden or 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
https://github.com/simonwagner/mergepbx | |
cloneする。 | |
mergepbxプロジェクトに移動して | |
./build.py | |
~/.gitconfig に以下の設定を追加する | |
[merge "mergepbx"] | |
name = XCode project files merger | |
driver = mergepbx %O %A %B |