开发者

How do I code for different versions of iPhone OS in XCode?

开发者 https://www.devze.com 2023-01-13 17:23 出处:网络
I seem to have a bug because I\'开发者_JAVA技巧m using -[AVAudioSession setActive:withFlags:error:] in an iPhone project that is for 3.0 - 4.0.2. So I guess I need to put one of those #IF lines in, so

I seem to have a bug because I'开发者_JAVA技巧m using -[AVAudioSession setActive:withFlags:error:] in an iPhone project that is for 3.0 - 4.0.2. So I guess I need to put one of those #IF lines in, so I can get it to do different things based on the OS version... But I can't find out how to do it.


You simply have to check if the method you're trying to call really exists:

if ([AVAudioSession respondsToSelector:@selector(setActive:withFlags:error:)]) {
   // call it
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号