开发者

detecting and preventing crashed on older iOS (Suspecting EventKit)

开发者 https://www.devze.com 2023-02-05 00:07 出处:网络
Dear Scholars. I have created a simple application using the latest SDK (4.2.1), Which runs smoothly and error free on all devices with iOS 4.x.x.

Dear Scholars. I have created a simple application using the latest SDK (4.2.1), Which runs smoothly and error free on all devices with iOS 4.x.x.

Lately I am getting some comments from users with older iOS version complaining the application is crashing on start, on Apple's crash log I see nothing at all. Pushing my investigation forward, the only suspect I have at the moment is the开发者_如何学JAVA use of EventKit class, which if memory serves, where introduced only after iOS4.

I am using it very lightly in one of my classes, and it works perfectly on iOS4.2.1

#import <EventKit/EventKit.h>

//some time later

[self setADateInCal: [MyTimeArray objectAtIndex:0] :formatterDate];   

Thus my Questions:

  1. Can this be the issue that crashes my application on iOS < 4 ?

  2. How can I prevent it without dropping the feature for people with iOS4

  3. In general, How can I test this? I have the latest official iOS on my device and SDK, the simulator is limited to how back it can go in regrading to iOS version... any magical way to do so?


1.) Yes. If it wasn't in the API in <4.0 than anyone not running >4.0 will crash.

2.) Test to see if the class is available using NSClassFromString (Google for examples) and respondsToSelector in correspondence to see if the method you want is available to use in the OS version the client is running. You will also probably need to weak link the EventKit framework (again Google for how to do this).

3.) The only real way to test this is to keep a device at the OS you want to test. Personally, I have an old iPhone that I never update running 3.1.3 for things just like this. Alternatively, you can keep old installs of xcode+iOSSDK on different partitions or something and use their simulator. (for future updates i guess since you obviously haven't done this for <4.0). But no, there is no magical way to do this. sorry.

edit for clarity on Number 2: Basically you will check to see if the class/method you want is available on the OS version you are currently running, if it is you can use it, if not you will have to find a work around (omit completely or do it another way that is compliant with older versions).


Yes it could be causing the crash. Issues with missing libraries do not report anything in the apple crash log.

To prevent it from happening you need to do two things,

Weak link the event kit library in xcode.

Check for its existence in your code with something like ,

   if(!NSClassFromString(@"EKEventKit")){
       //do stuff with event kit
     }

The only way to test on the actual iOS version is to get hold of a physical device running ios < 4.

0

精彩评论

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

关注公众号