gpt4 book ai didi

iphone - [__NSArrayM getFileSystemRepresentation :maxLength:]: unrecognized selector sent to instance

转载 作者:行者123 更新时间:2023-11-28 22:45:25 25 4
gpt4 key购买 nike

我有以下代码来加载一些文件并将它们保存到磁盘:

NSDictionary *dictionary = [NSKeyedUnarchiver unarchiveObjectWithData:[NSData dataWithContentsOfURL:url]];
// THE LINE BELOW IS WHERE THE EXCEPTION OCCURS
NSMutableArray *paths = [[NSMutableArray alloc] initWithArray:[NSKeyedUnarchiver unarchiveObjectWithFile:[dictionary objectForKey:@"paths"]]];

if(dictionary)
{

dispatch_async(dispatch_get_main_queue(), ^{

NSLog(@"DOWNLOADED PATHS: %@", paths);

NSFileManager *filemgr;
NSString *docsDir;
NSArray *dirPaths;

filemgr = [NSFileManager defaultManager];

dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

docsDir = [dirPaths objectAtIndex:0];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

for(NSObject *obj in paths)
{

NSString *identification = [defaults objectForKey:@"LatestID"];

NSString *pageno = [NSString stringWithFormat:@"%i", [paths indexOfObject:obj]];
NSString *name = [NSString stringWithFormat:@"%@paths%@.archive", identification, pageno];

NSString *dataFilePath = [[NSString alloc] initWithString: [docsDir
stringByAppendingPathComponent:name]];

[NSKeyedArchiver archiveRootObject:paths toFile:dataFilePath];

}

});

}

但是,当我运行这段代码时,出现以下异常:

enter image description here

* 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSArrayM getFileSystemRepresentation:maxLength:]: 无法识别的选择器发送到实例 0xc8809e0”* 首先抛出调用栈:(0x3623012 0x3448e7e 0x36ae4bd 0x3612bbc 0x361294e 0x2e2d7b4 0x2e2d762 0x2e5bc85 0x2e83c7a 0x8d98 0x406053f 0x4072014 0x4063 2e8 0x4063450 0x95336e12 0x9531ecca)libc++abi.dylib:终止调用抛出异常(lldb)

为什么会这样?

最佳答案

可疑行上的 [dictionary objectForKey:@"paths"] 似乎包含 NSMutableArray 而不是 NSString。也许您的意思是 [[dictionary objectForKey:@"paths"] objectAtIndex:0]

关于iphone - [__NSArrayM getFileSystemRepresentation :maxLength:]: unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13330135/

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