views:

116

answers:

2

Hi all,

I am developed one iPhone application which is working good in iphone 3.0.

While i am doing comparability with 4.0 it is giving some deprecated workings.

Please find the code below.....

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

Note: this is working fine in 3.0 but giving warning in 4.0

[[UIApplication sharedApplication] setStatusBarHidden:YES
                                        withAnimation:UIStatusBarStyleDefault];

Note: this is working fine in 4.0 but not at all working in 3.0.

My coding part almost completed, I need to publish this application ASAP.

Please help me out in this issue.

Thanks in advance.

+1  A: 

You have two main options:

  1. if you use setStatusBarHidden:animated: in 4.0, it will work. It's deprecated, which means you should avoid it, but it will still work — for now.

  2. Check at runtime which one is the best option:

if ([UIApplication instancesRespondToSelector:@selector(setStatusBarHidden:withAnimation:)]) {
    // use 4.0 method
} else {
    // use 3.0 method
}
jtbandes
Yes,I used this code earlier, But the problem is not resolved.
vulvaji
A: 

The poper way of handling such issues is using the ‘instancesRespondToSelector‘ method to check out which version you are running on. There is a possibility to use also a pre compiler directive, but introspection is the way Apple recommends.

So check if the UIApplication object responds to the setStatusBarHidden:withAnimation selector Nd execute the 4.0 code otherwise call the 3.0 code.

GorillaPatch