ユーザーが入力したパスワードを保存するテキストファイルを使用して、簡単なパスワードで保護されたアプリを作成しようとしています。テキストフィールドの内容をファイルに保存し、最終的にそのファイルの内容をユーザーが別のテキストフィールドに入力した内容と比較したいと思います。これが私が持っているものです:
 //Setting the string to hold the password the user has entered
    NSString *createPassword1 = passwordSet.text;
    //creating a muttable array to store the value of createPassword1
    NSMutableArray *passwordArray = [NSMutableArray array];
    //storing createpassword1 into the first element of the array
    [passwordArray addObject:createPassword1];
    NSLog(@"%@",[passwordArray objectAtIndex:0]);//seeing if it is stored correctly (it is)
    //path for searching for the file
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    //my filename
    NSString *fileName = @"PasswordFile.txt";
    NSString *fileAndPath = [path stringByAppendingPathComponent:fileName];
    if (![[NSFileManager defaultManager] fileExistsAtPath:fileAndPath]) {
        [[NSFileManager defaultManager] createFileAtPath:fileAndPath contents:nil attributes:nil];
    }
    [[[passwordArray objectAtIndex:0] dataUsingEncoding:NSUTF8StringEncoding] writeToFile:fileAndPath atomically:YES];
どんな助けでも大歓迎ですありがとう。