- (void)viewDidLoad
{
[super viewDidLoad];
if ([[NSFileManager defaultManager] fileExistsAtPath:pathString])
{
infoDict = [[NSMutableDictionary alloc] initWithContentsOfFile:pathString];
}
else
{
infoDict = [[NSMutableDictionary alloc]initWithObjects:[NSArray arrayWithObjects:@"BeginFrame",@"EndFrame", nil] forKeys:[NSArray arrayWithObjects:[NSNumber numberWithBool:YES],[NSNumber numberWithBool:YES], nil]];
if ([infoDict writeToFile:pathString atomically:YES])
{
NSLog(@"Created");
}
else
{
NSLog(@"Is not created");
NSLog(@"Path %@",pathString);
}
}
これは私のコードです。私はファイルが作成されているかどうかを確認します。 - NSMutableDictionary
を作成し、パスのファイルに書き込みますが、writeToFile
メソッドはNO
を返します。問題はどこですか? NSFileManager
でこのファイルを作成しても動作しますが、辞書を書きたいときはありません。なぜNSMutableDictionaryはファイルに書き込みをしたくないのですか?
'pathString'から来るのでしょうか? – Eimantas
私は[[NSFileManager defaultManager] createFileAtPath:pathString contents:nil attributes:nil]と言っています。このファイルは作成されました... –
私は最初のmetode initを持っています。私はそれを割り当てます –