PDA

View Full Version : Cocoa programming according to OSX Version




satyam90
Apr 3, 2008, 04:12 AM
In Cocoa using Obj C programming"
I found some of the methods like NSFileManager's "createDirectoryAtPath:withIntermediateDirectories:attributes:error:" works only with OSX 10.5 and above. There are few other methods similar to that. In my application, I want to check the OSX Version and depending on the version, I want to implement the code accordingly. Is it possible to check the OSX version programatically and implement the code?



Eraserhead
Apr 3, 2008, 06:37 AM
Well you have to build it against the appropriate SDK, why not just stick with the 10.4 methods?

titaniumdecoy
Apr 3, 2008, 01:40 PM
CocoaDev: Determining OS Version (http://www.cocoadev.com/index.pl?DeterminingOSVersion)

satyam90
Apr 4, 2008, 02:19 AM
CocoaDev: Determining OS Version (http://www.cocoadev.com/index.pl?DeterminingOSVersion)

I visited above site before posting the question. But it consists only upto 10.3.5 , but I am looking to have differences between 10.4 and 10.5

I am planning to migrate from 10.4 to 10.5 and so if my code consists of functions that can be used directly that works on 10.5, it might work faster.

Soulstorm
Apr 4, 2008, 03:40 AM
I visited above site before posting the question. But it consists only upto 10.3.5 , but I am looking to have differences between 10.4 and 10.5

I am planning to migrate from 10.4 to 10.5 and so if my code consists of functions that can be used directly that works on 10.5, it might work faster.

Actually, in the above link I also see some code that will return the exact version of the system. It's the code that uses Gestalt.

Also, functions such as the one you describe are added for ease of use and to improve functionality, not performance. Check the documentation. Unless Apple says that a method is deprecated. you can use it and be sure that it will work on the current system and at least in the next major revision of OS X. So, you can use "createDirectoryAtPath:attributes:error" without worrying about having to use one or another. This function will work on OS X 10.0 and later.

It's best not to implement version-specific code until you really need to. If you really need to implement a function because it allows you to do something that otherwise you couldn't, then you should do it. Otherwise, you tend to break compatibility with earlier versions of OS X, and to restore it, you will need to write more error-prone code.

Just a thought.