开发者

iOS4 code on iOS3 devices

Is it possible to have iOS4 specific code (ie the MKMapView overlays) in an application, build using 4.0, set the Deployment Target to 3.0, and still have it work so long as the iOS4 c开发者_如何学Code isn't called on a 3.x device?

I am trying to do that now, and only calling the iOS4 code if the device supports it, but I can't get it installed. GDB is freaking out. Here's what I get when I build for an iOS3 device:

dyld: Symbol not found: _OBJC_CLASS_$_MKOverlayView
Referenced from: /var/mobile/Applications/1EE8EC13-FA01-43CB-A617-9B5D268ECD13/maps.app/maps
Expected in: /System/Library/Frameworks/MapKit.framework/MapKit

Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.)
mi_cmd_stack_list_frames: Not enough frames in stack.
mi_cmd_stack_list_frames: Not enough frames in stack.

I want this application to run on 3.0 and up, and use the new MKMapView overlay on 4.0 devices.

Specifically, I am implementing the tiled image overlay code demonstrated at WWDC, which uses a custom TileOverlay that implements the MKOverlay protocol, and a custom TileOverlayView which is a subclass of MKOverlayView.


You need to build with the Base SDK set to 4.0 and the Deployment Target set to 3.0.

Then, when trying to use a class that only exists in 4.0, use NSClassFromString("MKOverlayView") or whatever it's called. That will return nil if the class doesn't exist.

This post from Matt Gallagher has more detailed tips for this kind of situation:

http://cocoawithlove.com/2010/07/tips-tricks-for-conditional-ios3-ios32.html


Try weak linking the MapKit framework.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜