1
원인 NSFileManager를 사용하여 파일 읽기 : 오류의 원인오류 나는 다음과 같은 오류를 얻고있다
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'
*** First throw call stack:
코드 것은 다음 plistData가 null이기 때문에
NSDictionary *dict = nil;
@synchronized(self) {
dict = [pendingDictionarySaves objectForKey:file];
}
if (dict) return dict;
@synchronized(self) {
dict = [savedDictionaries objectForKey:file];
}
if (dict) return dict;
NSData *plistData = [[NSFileManager defaultManager] contentsAtPath:file];
NSError *error = nil;
if ([[NSPropertyListSerialization class]
respondsToSelector:@selector(propertyListWithData:options:format:error:)]) {
return [NSPropertyListSerialization propertyListWithData:plistData
options:NSPropertyListImmutable
format:NULL
error:&error];
}
는 기본적으로 이유입니다. 파일 경로는 다음과 같습니다
/Users/aditya15417/Library/Application Support/iPhone Simulator/5.1/Applications/A355D003-668C-4B81-80DC-66C968FE57D3/Library/Caches/NewsfeedCache/?type=news
여기에 내가 경로를 초기화하는 방법은 다음과 같습니다
NSString *path = [basePath stringByAppendingPathComponent:[streamURL uniqueFileName]];
// Create the directories if needed
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
[[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:NO attributes:nil error:nil];
}
return path;
문제는 그것이 가능하다이 pListData가 null의 경우 확인하지 않고 작동하도록하는 방법은?
이제 문제가 무엇인지 알았습니다. 무엇이 문제입니까? –
basePath 란 무엇입니까? – user523234
파일 경로 앞에 실제 파일 이름이없는 URL 매개 변수가 파일 경로에있는 이유는 무엇입니까? – sosborn