NSData 相互変換 NSString
NSData >> NSString
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString >> NSData
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
UIScrollView(UITableView)に余白を設定する
以下の方法でUIScrollView(UITableView)に余白を設定する事ができます。
self.scrollView.contentInset = UIEdgeInsetsMake(10.0f, 20.0f, 30.0f, 40.0f);
UIEdgeInsetsMakeの設定は左から(上・左・下・右)の順序になります。
※使い道は色々、たまに価値があります。
スレッドを一時停止(スリープ)
さんぽです。。。
スレッドの処理を一定時間停止するには以下のメソッドを呼び出します。
// 1秒停止する場合
[
NSThreadsleepForTimeInterval:1.0f];
Info.plistファイルの値を取得するには
Info.plistファイルの値を取得するには、以下を記載します。
[[NSBundle mainBundle] objectForInfoDictionaryKey: @"Info.plistのキー"];
Info.plistキーは、以下の手順で確認することができます。
①Info.plistファイルを開く
②右クリック
③「Show Raw Keys/Values」を選択
これでキーが確認できます。
例:「Bundle version」が「CFBundleVersion」になっています
この場合、アプリのバージョンを取得するには
[[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleVersion"];
となります。