Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

roublesaha

macrumors newbie
Original poster
Dec 22, 2008
9
0
Hi All

I have a snippet of code which works in 10.4 but it supported in 10.3.

Hence i want some APIs to determine the OS , so that the snippet gets executed in the proper OS.

Also, please let me know if u have any better way to distinguish between the versions programmatically.

I am working with C++ source code
 
You can call Gestalt() with gestaltSystemVersionMajor and gestaltSystemVersionMinor.
 
thanks........i will try that..

but i guess that is available in 10.4 onwards....i need for 10.3 and onwards.:(
 
Why do you say that? It is supported in 10.3. I am looking at the header file from the 10.3.9 SDK right now :)
 
ok i am also using 10.3.9...

I am not able to use it properly.Please help me out

Can u please give an wxample how to use this......
 
But can please u tell me how to do the following :

I want to compare the value returned by ( NSString *str = [[NSProcessInfo processInfo] operatingSystemVersionString] ) with 10.4

.If it is less than that execute one piece of code otherwise if it is greater then execute other piece of code.
 
Check out this method in the NSString Class:

caseInsensitiveCompare:
Returns the result of invoking compare:eek:ptions: with NSCaseInsensitiveSearch as the only option.

- (NSComparisonResult)caseInsensitiveCompare:(NSString *)aString

I will write it below, but I have not written Cocoa in awhile for forgive me for any mistakes...

Code:
NSString *str = [[NSProcessInfo processInfo] operatingSystemVersionString];

if ([str caseInsensitiveCompare:@"10.4.1"] == NSOrderedAscending) {

/*execute some code here.......*/


}

You should get the idea.
 
But can please u tell me how to do the following :

I want to compare the value returned by ( NSString *str = [[NSProcessInfo processInfo] operatingSystemVersionString] ) with 10.4

.If it is less than that execute one piece of code otherwise if it is greater then execute other piece of code.

That kind of thing broke lots of applications when 10.4.10 was released (and some stupid code believed that 10.4.10 is less than 10.4.3, for example).

The Gestalt code works.

ok i am also using 10.3.9...

I am not able to use it properly.Please help me out

Can u please give an wxample how to use this......

developer.apple.com, type in "Gestalt" and see what happens.
Or start XCode, type "Gestalt" into any file, double click on it to select the word, then right click + select "Show API Reference" or "Show Definition".
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.