본문 바로가기
모바일개발(Mobile Dev)/IOS개발(ObjectC)

IOS image file path

by 테크한스 2015. 11. 28.
반응형

In iOS 8, Te file system layout of app containers has changed. Applications and their content are no longer stored in one root directory.

From the iOS 8 Release Notes:

The file system layout of app containers has changed on disk. Rather than relying on hard-coded directory structure, use the NSSearchPathForDirectoriesInDomains function or theURLForDirectory:inDomain:appropriateForURL:create:error: method of theNSFileManager class. See Accessing Files and Directories in File System Programming Guide.

This is not a bug. Make sure you use the reccomended APIs (from the above quote) and you won't have a problem.

So, If you are trying to access a bundled resource you added to the project, you would use:

[[NSBundle mainBundle] pathForResource:@"resourceName" ofType:@"extension"];

But if you want to use something that you put in the documents directory, you would use:

[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"resourceName.extension"];


반응형