推荐的方式支持iPhone应用程序的向后/向前兼容性? [英] Recommended way to support backward/forward compatibility in iPhone app?

查看:131
本文介绍了推荐的方式支持iPhone应用程序的向后/向前兼容性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正处于iPhone应用程序的早期阶段,我有一个问题。我做了一些搜索,但没找到我要找的东西。

I'm in the early stages of an iPhone app and I have a question. I did some searching but did not find what I was looking for.

我想利用iPhone OS4中的功能,但我想要我的应用程序也在3.X上运行。

There are features in iPhone OS4 that I would like to take advantage of, but I would like for my app to also run on 3.X.

看起来我想针对4.0 SDK开发并执行以下操作:

It looks like I want to develop against the 4.0 SDK and do the following:


  1. 为任何新的(4.0)框架创建弱链接

  2. 调用 respondsToSelector:现有框架中的任何
    新方法
    或新框架中的任何方法
    拨打电话之前

  1. Create a "weak link" to any new (4.0) frameworks
  2. Call respondsToSelector: for any new method in an existing framework or any method in a new framework before making that call

我关闭了吗?推荐什么?

Am I close? What's recommended?

欢迎提出类似问题的指示。

Pointers to similar questions welcome.

更新:
就像一个注释 - 如果你正在尝试检查一个新框架,你最好的机会是对类对象的类方法调用 respondsToSelector:而不是使用实例方法。

UPDATE: Just as a note - if you are trying to check for a new framework, you're best chance is to call respondsToSelector: on a class method against the class object instead of using an instance method.

推荐答案

是的,这正是你的做法!

Yes, that's exactly how you do it!

我能想到的另一个你还没有提到过的另一个技巧就是你构建了最新的SDK(在这种情况下是4.0)并将目标设置为你想要支持的最早的目标(3.0 in这种情况)。

The only other trick I can think of that you have not already mentioned is that you build against the latest SDK (i.e., 4.0 in this case) and set the target to be the earliest you want to support (3.0 in this case).

您可能想尝试使用3.2 SDK创建通用(iPhone / iPad)应用程序。这是一个Apple模板,它使用相同的方法处理两个不同的API。

You might like to try using the 3.2 SDK to create a universal (iPhone/iPad) app. This is an Apple template that uses this same method to work with two different APIs.

这篇关于推荐的方式支持iPhone应用程序的向后/向前兼容性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆