0

ファイル共有フォルダーにある plist ファイルを開いて、アプリを起動するたびに 2 つのユーザー情報を追加する必要があります。ユーザーの新しい名前と電子メールのように (どちらも NSString 型で、plist ファイルは Dictionary です)。

次に、新しく更新された plist ファイルを後で iTunes 経由で削除できるように、ファイルを再度ファイル共有フォルダーに保存する必要があります。

誰かがそれを助けることができれば、それは大歓迎です

4

2 に答える 2

2

Documents ディレクトリに plist を保存することができます。plist を NSMutableDictionary にロードし、辞書を変更して Documents ディレクトリに書き戻すことができます。

// get the path to the plist file
NSArray *paths =  NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  NSUserDomainMask, YES); 
NSString *documentsPath = [paths objectAtIndex:0]; 
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"myfile.plist"];

// read the plist into an NSMutableDictionary
NSMutableDictionary *plistDictionary = [NSMutableDictionary dictionaryWithContentsOfFile:filePath];

// make the additions to the plistDictionary

// write the plist back to the documents directory
[plistDictionary writeToFile:filePath atomically:YES];

iTunes経由でplistを削除できるかどうかはわかりません。

于 2010-09-23T01:16:16.280 に答える
0

私が見つけたもう 1 つの優れたリソースは、次の場所にある「Humble Coder's」ブログの記事です。すばらしいアドバイスとサンプル コードは、plist ファイルの取得と更新を保存する必要があるという私のニーズにぴったりでした。助けてくれた人々に改めて感謝します。

http://humblecoder.blogspot.com/2010/03/revisited-storing-and-retriving.html

于 2010-09-23T13:56:12.543 に答える