LoginSignup
34
34

More than 5 years have passed since last update.

iTunesを使ったファイル共有方法

Last updated at Posted at 2014-02-20

iTunesからファイルを共有してアプリから利用する方法

プロジェクトの設定

  1. プロジェクトナビゲーターで「プロジェクト名-Info.plist」ファイルを選択
  2. 行を追加して「Key」に「Application supports iTunes file sharing」と入力して「Value」を「YES」に設定する iTunesSharing1.png

シミュレーターでのファイル追加方法

/Users/{ユーザー名}/Library/Application support/iPhone Simulator/ を開き
作成中のアプリケーションの Documents フォルダへファイルを作成またはコピーする。
iTunesSharing2.png

*実機の場合はiTunesから

アプリ側でのファイル読み込み

// ドキュメントディレクトリ
NSArray *documentDirectries = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [documentDirectries lastObject];

// ドキュメントディレクトリにあるファイルリスト
NSError *error = nil;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *files = [fileManager contentsOfDirectoryAtPath:documentDirectory error:&error];
for (NSString *file in files) {
    NSLog(@"%@", file);
}
34
34
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
34