diffの従業員が使用するiPhoneアプリを開発しました。組織 (実際には、エンタープライズ アプリにはしていません。代わりに、このアプリを有料でアプリ ストアに置く予定です) 。アップがそこに来て、URL の入力を求めます(これは、その人物の組織のサーバーへの URL ポイントになります)。したがって、コード ロジックをたどると、ビューのログイン ページにいつアクセスするかが必要になります。 URLがすでにアプリに保存されているかどうかを確認したい.保存されていない場合は、URLの入力を求めるポップアップを表示し、保存されている場合は、ログインの詳細を入力できるようにします.
私の問題は、その URL をどのように保存する必要があるか、その URL をどこに保存する必要があるか、およびそれが既に保存されているかどうかを確認する方法です。その URL を保存しようとしました... urlfield.text は、保存する URL です。
NSError *error;
// For error information
// Create file manager
fileMgr = [NSFileManager defaultManager];
// Point to Document directory
documentsDirectory = [NSHomeDirectory()
stringByAppendingPathComponent:@"Documents"];
fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath];
// File we want to create in the documents directory
// Result is: /Documents/file1.txt
filePath = [documentsDirectory
stringByAppendingPathComponent:@"file1.txt"];
str=urlField.text;
// Write the file
[str writeToFile:filePath atomically:YES
encoding:NSUTF8StringEncoding error:&error];
// Show contents of Documents directory
NSLog(@"Documents directory: %@",
[fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
そして、私はそこにあるかどうかを確認しています..
// fileExists is a BOOL variable
fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath];
NSLog(@"Boolean value:=%d",fileExists);
if ( fileExists == 0 )
{
.......
........
}
しかし、アプリを実行するたびに '0' (BOOL 変数 fileExists を意味します) が返されます。誰かが私の仕事を達成する方法を教えてください。私はこのロジックですべての側面を試すことになります。