私が試してみました:
path = @"~/Desktop/files/text.plist";
NSDictionary *aDict = [NSDictionary dictionaryWithContentsOfFile:path];
結果パス: ~/Desktop/files/text.plist
path = @"$(HOME)/Desktop/files/text.plist";
NSDictionary *aDict = [NSDictionary dictionaryWithContentsOfFile:path];
結果パス: $(HOME)/Desktop/files/text.plist
path = [NSHomeDirectory() stringByAppendingString:@"/Desktop/files/text.plist"];
NSDictionary *aDict = [NSDictionary dictionaryWithContentsOfFile:path];
結果パス: /Users/my_name/Library/Application Support/iPhone Simulator/5.1/Applications/639DC66A-7092-4ECB-9E48-59935AC1C394/Desktop/files/text.plist
- XCode でユーザーのデスクトップ パスにアクセスする方法はありますか?
- 上記の例で環境変数を使用できますか?また、その方法は?
編集: 2 番目の質問の詳細: MAC コンソールに環境変数 (またはマクロ) があるように、これらをコード内で使用することはできますか? それらが使用できる場合、誰かが例を手伝ってくれますか? $HOME_DIRECTORY など。