Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Prevent certain code from compiling?

Robert PaulsonRobert Paulson Posts: 492Registered Users
edited December 2010 in iPhone SDK Development
Hey,

we want to implement Game Center in our app but also want to make the app available for users with iOS versions that don't support GC (we have an alternative solution there).

We don't understand, however, how we can compile versions for, say, 3.2 and 4.1 given the same code.

This site suggests something like this:
#if __IPHONE_3_0
// Statement for SDK 3.0
#else
// Statement for older OS versions
#endif


On Apple's site, I found this method:
BOOL isGameCenterAvailable()
{
// Check for presence of GKLocalPlayer API.
Class gcClass = (NSClassFromString(@\"GKLocalPlayer\"));

// The device must be running running iOS 4.1 or later.
NSString *reqSysVer = @\"4.1\";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);

return (gcClass && osVersionSupported);
}


I feel like I have to combine these two approaches but can't figure out how. If I try to compile for version 3.2, xcode complains that it doesn't know GKLocalPlayer. Which, of course, makes sense. How can I prevent it from trying to run the code containing GKLocalPlayer etc. when compiling for older versions?

Thanks a lot for any hints!

Cheers,
Bob
Post edited by Robert Paulson on
We are God’s middle children, according to Tyler Durden, with no special place in history and no special attention.



Consider saying thanks by buying my app. :]

Replies

Sign In or Register to comment.