忘備録

日々の調べ物をまとめる。アウトプットする。基本自分用。

2015-10-09から1日間の記事一覧

【Objective-C】NSDateオブジェクトからエポック秒を取得する

NSDate timeIntervalSince1970プロパティを取得する NSDate *now = [NSDate date]; double timeInterval = [now timeIntervalSince1970]; 参考: NSDate Class Reference

【Objective-C】数値の絶対値を取得する

C言語の関数 abs などを使う Objective-Cと戦うブログ: NSDateでマイナスの値が返る場合はfabs関数で絶対値を取る fabs(int n) →int型の絶対値を取得する labs(long n) →long型の絶対値を取得する fabs(float n) →double型の絶対値を取得する

【Objective-C】NSIntegerがあって、NSDoubleがないわけ

objective c - Do NSDouble, NSFloat, or other types than NSInteger exist? - Stack Overflow NSInteger exists because the int type varies in size between 32-bit and 64-bit systems. float and double don't vary in size the same way, so there's …

【Objective-C】数値を文字列に変換

NSString + (instancetype)stringWithFormat:(NSString *)format を使う double number = 3.14; NSString *numberString = [NSString stringWithFormat:@"%f", number]; 参考:NSString Class Reference

【Objective-C】プロパティ名の制約

以下のようなコードを書いたところ。。。 hogehoge.h @property NSString *newHoge; Xcodeから以下のようにお叱りが。。。 Property follows Cocoa naming convention for returning 'owned' objects んで、調べてみた objective c - Semantic Issue: Proper…