gpt4 book ai didi

ios - NSDictionary writeToFile 不写

转载 作者:行者123 更新时间:2023-11-28 17:33:50 28 4
gpt4 key购买 nike

我使用有效的字典运行以下代码,但仍然“未写入”:

 NSFileManager* fm = [[NSFileManager alloc] init];
__autoreleasing NSError* err = nil;

NSURL* DD = [fm URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:&err];
if (!err) {
NSString* debugPath = [[DD path] stringByAppendingPathComponent:@"debug.plist"];

NSLog(@"login-signup write that file!");
NSDictionary* remMe = [NSDictionary dictionaryWithObjectsAndKeys:[userJSON objectForKey:kRememberMeToken],kRememberMeToken,[userJSON objectForKey:@"id"],@"id",nil];

NSMutableDictionary* toStore = [NSMutableDictionary dictionaryWithDictionary:dict];
[toStore setObject:Password.text forKey:kPassword];
NSMutableDictionary* toStoreTwo = nil;
if([fm fileExistsAtPath:debugPath]){
toStoreTwo = [NSMutableDictionary dictionaryWithContentsOfFile:debugPath];
[toStoreTwo setObject:[toStore copy] forKey:@"signup"];
[toStoreTwo setObject:remMe forKey:@"login"];
}
else{
toStoreTwo = [NSMutableDictionary dictionaryWithObject:[toStore copy] forKey:@"signup"];
[toStoreTwo setObject:remMe forKey:@"login"];
}

NSDictionary* sDict = [NSDictionary dictionaryWithObject:toStoreTwo forKey:[NSString stringWithFormat:@"signup-debug-%@",[NSDate date]]];

NSLog(@"saving %@ to file",sDict);
BOOL success = [sDict writeToFile:debugPath atomically:NO];
if(!success){
NSLog(@"not written");
}
else{
NSLog(@"written");
}
}

任何帮助都会很棒!

Stackoverflow 需要更多内容来解释代码,但我认为很容易看出发生了什么,如果您有任何问题,请发表评论!

最佳答案

看这个问题write to file fails .我有一些问题,但在检查我的字典中的所有数据类型后发现错误。

关于ios - NSDictionary writeToFile 不写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10423419/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com