2012년 8월 27일 월요일

IOSデータ保護方法

※iOS 4 以降、データ保護機能が提供されるようになりました。
データ保護機能を有効にするにはパスコードロックを有効にする必要がある



【NSFileManager】
NSDictionary* attributes = [NSDictionary dictionaryWithObject:NSFileProtectionComplete forKey:NSFileProtectionKey];
NSError* error = nil;
[fileManager setAttributes:attributes ofItemAtPath:filePath error:&error];


【NSData】
NSError* error = nil;
NSData* data = [NSData dataWithContentsOfFile:src1];
[data writeToFile:filePath options:NSDataWritingFileProtectionComplete error:&error];

2012년 8월 21일 화요일

CoreData データモデル属性













Attribute


【オプション/Option】
オプションにチェックをした場合、Entityは、そのAttributeが値を持たない場合でも保存可能である。逆に、オプションではないAttributeに値がセットされていない状態でEntityを保存しようとするとエラーが返される。
そのAttributeが必須項目であれば、オプションからチェックをはずし、そうでなければチェックしておけばよい。

【一時/Transient】
一時的なAttributeは、生成はされるが、ディスク上(Persistent store)には保存されない。
臨時保存先となります。

【索引付き/Indexed】
索引付きにチェックをした場合、このAttributeはデータ保存時にインデックスを作成する。
このインデックスは、データベース内の検索を高速化するために用いられる。
該当Attributeを用いて検索やソートを行う場合、索引付きにしておくことでかなりの高速化効果が期待できる。しかしながら、検索やソートに用いないのであれば、逆効果を招きかねないのでチェックすべきではない。DBに保存時インデックス作成しているので保存時間がかかります。

【Attribute Type】
- Integer 16:-32,768 to 32, 767
- Integer 32:-2,147,483,648 to 2,147,483,647
- Integer 64:-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

2012년 8월 20일 월요일

モダルビューアからキーボードを非表示にする方法


- (IBAction)close:(id)sender {
    [textField resignFirstResponder];
    @try
    {
        Class UIKeyboardImpl = NSClassFromString(@"UIKeyboardImpl");
        id activeInstance = [UIKeyboardImpl performSelector:@selector(activeInstance)];
        [activeInstance performSelector:@selector(dismissKeyboard)];
    }
    @catch (NSException *exception)
    {
        NSLog(@"%@", exception);
    }
}

2012년 8월 15일 수요일

Xcode 4におけるiOS Frameworkの作成方法(URL参照)

http://mobileapplication.blog.fc2.com/blog-entry-8.html
http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/

UITextView コピー禁止する方法


@implementation UITextView(Private)
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
[UIMenuController sharedMenuController].menuVisible = NO; //do not display the menu
[self resignFirstResponder]; //do not allow the user to selected anything
return NO;
}
@end
上記カテゴリを追加する

IOS デバイス使用可能容量取得


デバイスのルートディレクトリには、/etcと/varというフォルダがあるようです。
基本的なアプリは/varに入ります。/etcはおそらくシステムフォルダでしょう。

【例】
NSDictionary *dict = [[NSFileManager defaultManager] fileSystemAttributesAtPath:@"/var" ];

NSNumber *free = [dict valueForKey:NSFileSystemFreeSize];<br />NSNumber *system = [dict valueForKey:"NSFileSystemSize"];
NSLog("free:%.3f",[free floatValue]/1024/1024/1024);<br />NSLog("sys:%.3f",[system floatValue]/1024/1024/1024);

IOS イメージサイス整理


Application icon (in pixels)
iPad:72x72
iPad Retina:144x144
iPhone:57x57
iPhone Retina:114x114

Launch image (in pixels)
iPad:768 x 1004 (portrait) 1024 x 748 (landscape)
iPad Retina:1536 x 2008 (portrait) 2048 x 1496 (landscape)
iPhone:320 x 480
iPhone Retina:640 x 960

Tab bar icon (in pixels)
iPad:Approximately 30 x 30
iPad Retina:Approximately 60 x 60
iPhone:Approximately 30 x 30
iPhone Retina:Approximately 60 x 60

Toolbar and navigation bar icon (in pixels)
iPad:Approximately 20 x 20
iPad Retina:Approximately 40 x 40
iPhone:Approximately 20 x 20
iPhone Retina:Approximately 40 x 40

IOS5.0.1からDocumentフォルダがiTunesとiCloudバックアップ対象外設定できる


IOS5.0.1以後、Documentフォルダのファイルをバックアップ(iTunesとiCloud)対象外にするとこができるようになりました。
以下のURLを参考してください。
http://developer.apple.com/library/ios/#qa/qa1719/_index.html#//apple_ref/doc/uid/DTS40011342

IOS5以後、Cachesフォルダシステムが削除する


IOS5以後、Library/Cacheフォルダのファイルを使用可能容量が
100MB~0MB(想定)の場合システムが自動に削除するようになりました。
以下のURLを参考してください。
https://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html%23//apple_ref/doc/uid/TP40010672-CH2-SW2