1

iOS SDK is upgrading, and some new tech will appear, i.e, block is new tech.

So question is if "block" based implementation also can be distributed to lower target version or older iPhone ( 3G or first generation ) ?

how to cope with those issues ?

Forrest
  • 122,703
  • 20
  • 73
  • 107

2 Answers2

0

The usual way to deal with this sort of issue is to selectively enable features at runtime based on the current OS version. However, this can be very complicated to manage.

  • Query the current OS version at runtime
  • Use weak linking
  • Dynamically create the class
  • Call the new features only if the new class is present

For example:

Class optionalClass = NSClassFromString(@"NSArtificialIntelligence");
if (optionalClass) {
  id optionalObj = [[optionalClass alloc] init];
  // ... 
}

The following documentation describes the process in detail:

You specifically mention blocks. This feature requires support from the compiler and Objective-C runtime, so it will not be available at all on older systems.

gavinb
  • 19,278
  • 3
  • 45
  • 60
  • thanks for your answers. block is just one example. developers want to use latest tech,but the app want to be installed for lowest SDK, for as far as more devices. Yes,this is conflicted. To know more deeply,any good practice to handle this type issue ? Thanks again – Forrest Apr 25 '11 at 08:19
0

You must weak link to libSystem.B.dylib if you are using blocks for iOS4 or later. Because blocks are able to compile with the latest iOS SDK but iOS2,3.0 and 3.1 don't have blocks runtime.

(Besides, you can use blocks for iPhone 2.2+. Please take a look at plblocks.)

Community
  • 1
  • 1
Kazuki Sakamoto
  • 13,929
  • 2
  • 34
  • 96