【NSFileManager】iPhone内のファイルを探す

Posted by: daichi  /  Category: iphone開発

NSFileManager

システムサウンドのようなiPhone内のファイルをNSFileManagerで探す方法。

NSFileManagerのメソッドで以下の3つ方法で取得できる。

  • directoryContetnsAtPath
  • subpathsAtPath
  • enumeratorAtPath
それぞれ順に、サブディレクトリを含まないファイル名リスト、サブディレクトリを含むファイル名リスト、enumeratorを取り出せる。

以下は/System/Library/Audio/UISoundsにあるファイル一覧を出力するサンプルコード。



?View Code OBJECTIVE-C
	NSFileManager *fileManager;
	NSArray *array;
 
	fileManager = [NSFileManager defaultManager];
	array = [fileManager directoryContentsAtPath:@"/System/Library/Audio/UISounds/"];
	NSLog([array description]);


結果はこんな感じ。
ちなみに出力結果はOS2.xではないため、現行端末では少し内容が違うかもしれない。

(
“ReceivedMessage.caf”,
“RingerChanged.caf”,
“SIMToolkitCallDropped.caf”,
“SIMToolkitGeneralBeep.caf”,
“SIMToolkitNegativeACK.caf”,
“SIMToolkitPositiveACK.caf”,
“SIMToolkitSMS.caf”,
“SentMessage.caf”,
“Tink.caf”,
“Tock.caf”,
“Voicemail.caf”,
“alarm.caf”,
“beep-beep.caf”,
“begin_record.caf”,
“begin_video_record.caf”,
“ct-busy.caf”,
“ct-call-waiting.caf”,
“ct-congestion.caf”,
“ct-error.caf”,
“ct-keytone2.caf”,
“ct-path-ack.caf”,
“dtmf-0.caf”,
“dtmf-1.caf”,
“dtmf-2.caf”,
“dtmf-3.caf”,
“dtmf-4.caf”,
“dtmf-5.caf”,
“dtmf-6.caf”,
“dtmf-7.caf”,
“dtmf-8.caf”,
“dtmf-9.caf”,
“dtmf-pound.caf”,
“dtmf-star.caf”,
“end_record.caf”,
“end_video_record.caf”,
“jbl_ambiguous.caf”,
“jbl_begin.caf”,
“jbl_cancel.caf”,
“jbl_confirm.caf”,
“jbl_no_match.caf”,
“lock.caf”,
“long_low_short_high.caf”,
“low_power.caf”,
“mail-sent.caf”,
“middle_9_short_double_low.caf”,
“new-mail.caf”,
“photoShutter.caf”,
“shake.caf”,
“short_double_high.caf”,
“short_double_low.caf”,
“short_low_high.caf”,
“sms-received1.caf”,
“sms-received2.caf”,
“sms-received3.caf”,
“sms-received4.caf”,
“sms-received5.caf”,
“sms-received6.caf”,
“sq_alarm.caf”,
“sq_beep-beep.caf”,
“sq_lock.caf”,
“sq_tock.caf”,
“unlock.caf”,
“ussd.caf”
)


関連のあるアプリ

islot_icon
iSlot Pro 2009/03/13 リリース
ファイナンス 350円
パチスロ収支管理アプリ
app_store_badge

タグ: iphone, iSlot, iSlot Pro, NSArray, NSFileManager, objecti, objective-c, photo, アプリ, パチスロ, リスト, リリース, 収支

関連する投稿

コメント

Additional comments powered by BackType

Get Adobe Flash playerPlugin by wpburn.com wordpress themes