ユーザーはあなたが合意の値(おそらくBollean)を格納よりも契約書に同意した場合は、おそらくのドキュメントディレクトリから(plistファイルにアルタービューを通じて
と
を契約ページを適用することができますそれは一度
のために受け入れられると協定を表示しないようにするためのアプリ)の各時間より を、あなたはそれを
![enter image description here](https://i.stack.imgur.com/Q9Il1.png)
CODEを確認することができます
-(void)CopyPlistTODocument
{
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath= [documentsDirectory stringByAppendingPathComponent:@"Settings.plist"];
success = [fileManager fileExistsAtPath:writableDBPath];
if (success) return;
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Settings.plist"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success) {
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}
//NOW Call Another method that read data form plist of document directory
-(void)desclaimer
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *path =[documentsDirectoryPath stringByAppendingPathComponent:@"setting.plist"];
NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile: path];
BOOL *temp=[plist valueForKey:@"Agreement"];
//if the value of the temp got YES That Agreed earlier so no need to agreed again
if ([temp isEqualToString:@"NO"])
{
//Show Alert View From Here And call Method Accept() on the button pressed event of the accept button
}
}
//Now From Button Pressed Event Of The Accept Here is the Accept method
-(void)Accept
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *path =[documentsDirectoryPath stringByAppendingPathComponent:@"Settings.plist"];
NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile: path];
[plist setValue:@"YES" forKey:@"Agreement"];
//now every time the value read from here has agreed state so alert view will not get called
[plist writeToFile:path atomically:YES];
}
私はこれをどうすれば説明できますか? – Ajay
更新されたコードを確認してください – NIKHIL
どこにこのコードを書くべきですか?より良い理解 – Ajay