Chapter on dual iOS6 and iOS7 apps suggestion

This is the official forum for iOS 7 By Tutorials, by the iOS Tutorial Team.

Chapter on dual iOS6 and iOS7 apps suggestion

Postby jvanlint » Mon Sep 23, 2013 7:57 am

Hi guys,
Excellent work on the book. Very helpful for knowledgeable programmers needing a guide to transition from 6 to 7.

Just one suggestion. In the chapter on maintaining a 6 and 7 codebase the author mentions using if statement to determine whether you are running iOS6 or 7.

It might be worth showing what one of these statements actually looks like. I was hoping for an example in the book and now I have to go to the Internet to find it (which aint a bad thing but an trivial example would be a good thing).
jvanlint
Uber Haxx0r
 
Posts: 116
Joined: Wed Oct 19, 2011 9:26 pm
Has thanked: 1 time
Been thanked: 17 times

Re: Chapter on dual iOS6 and iOS7 apps suggestion

Postby Hollance » Mon Sep 23, 2013 8:15 am

They are on the previous page:

Code: Select all
if ([self.tableView respondsToSelector:@selector(tintColor)]) {
   ...
}


It might be a bit misleading that it says "if (on iOS 6)" but you usually don't want to check for an explicit iOS version, but instead you check whether a certain feature is available.
User avatar
Hollance
Team Member
iOS Tutorial Team Member
 
Posts: 4353
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 544 times

Re: Chapter on dual iOS6 and iOS7 apps suggestion

Postby jvanlint » Mon Sep 23, 2013 8:18 am

Does this mean iOS7 would not respond to this?

Code: Select all
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];
jvanlint
Uber Haxx0r
 
Posts: 116
Joined: Wed Oct 19, 2011 9:26 pm
Has thanked: 1 time
Been thanked: 17 times

Re: Chapter on dual iOS6 and iOS7 apps suggestion

Postby jvanlint » Mon Sep 23, 2013 8:20 am

In the above sceanrio I would like to execute this for iOS6 but not for iOS7. Would your posted answer cater for this? I would do a test for respondToSelector:setBackgroundImage?
jvanlint
Uber Haxx0r
 
Posts: 116
Joined: Wed Oct 19, 2011 9:26 pm
Has thanked: 1 time
Been thanked: 17 times

Re: Chapter on dual iOS6 and iOS7 apps suggestion

Postby Hollance » Mon Sep 23, 2013 10:47 am

No, in case you want to do something only on iOS 6 you would not use respondsToSelector. In that case you would check the operating system version indeed.
User avatar
Hollance
Team Member
iOS Tutorial Team Member
 
Posts: 4353
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 544 times

Re: Chapter on dual iOS6 and iOS7 apps suggestion

Postby jvanlint » Mon Sep 23, 2013 11:41 am

So I wonder if this is worth mentioning. How to do an OS check. Or.....no?
jvanlint
Uber Haxx0r
 
Posts: 116
Joined: Wed Oct 19, 2011 9:26 pm
Has thanked: 1 time
Been thanked: 17 times

Re: Chapter on dual iOS6 and iOS7 apps suggestion

Postby Hollance » Mon Sep 23, 2013 12:42 pm

Yes, it's worth mentioning. :-)
User avatar
Hollance
Team Member
iOS Tutorial Team Member
 
Posts: 4353
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 544 times

Re: Chapter on dual iOS6 and iOS7 apps suggestion

Postby jvanlint » Mon Sep 23, 2013 1:40 pm

From Apple documentation, they suggest this way

Code: Select all

    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {

    // Load resources for iOS 6.1 or earlier

    } else {

    // Load resources for iOS 7 or later

    }

jvanlint
Uber Haxx0r
 
Posts: 116
Joined: Wed Oct 19, 2011 9:26 pm
Has thanked: 1 time
Been thanked: 17 times


Return to iOS 7 By Tutorials Official Forum

Who is online

Users browsing this forum: No registered users and 2 guests