Question

I have the following line of code in my program which I took from the Forth edition of Stephen G. Kochan's book "Programming in Objective-C:

[fileManager createDirectoryAtPath:DATABASE_DIRECTORY attributes:nil];

Note: "fileManager" is my fm variable, and DATABASE_DIRECTORY is a #define of my path.

While it works perfectly fine (I'm running OSX 10.6.8), every time I compile I am reminded that:

"createDirectoryAtPath:attributes:" is deprecated

I've looked over the reference document for the file manager, and it is a bit overwhelming for a newbie to Cocoa Programming. Regardless, that particular method is no longer listed in the only filemanager reference docs I could find (https://developer.apple.com/library/mac/#documentation/Carbon/Reference/File_Manager/Reference/reference.html) It is not even listed as "deprecated". It's just not there at all.

Clearly, it still works, but obviously the idea is to utilize a different and more modern way of creating a directory (I noticed that the filemanager reference is a Carbon vs. Cocoa reference. I have not tried running this on Lion yet to see if it still works.)

Is there a direct replacement for this deprecated method?

If not, is Apple trying to do away with path names and instead switch over to Unicode entirely? (Forgive me if I'm a bit confused on this issue and terminology... I haven't written code since the late 80's...) I have never really used Unicode for anything in the past so I wouldn't know where to begin.

If anyone can recommend a good current primer on Unicode and/or programming code to read/write files in Cocoa, it would be greatly appreciated!

Was it helpful?

Solution

What Apple is doing is moving away from paths toward URLs -- I don't know if they will go all the way, but they do seem to be depreciating quite a few of the path methods in favor of URL ones. The replacement for createDirectoryAtPath:attributes: is createDirectoryAtURL:withIntermediateDirectories:attributes:error:

I'm not sure why you couldn't find that in the docs, if you search for createDirectoryAtPath:attributes: it takes you to the depreciated methods and in that reference it points you to the replacement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top