Search code examples
iosprintingweak-linking

Weak Linking Framework for Printing


I have a simple project that uses mail and print routines. For printing, i have a subclass of UIPrintPageRenderer. I'm following Apple's guidelines for using weakly linked classes:

- The base SDK for your Xcode project must be iOS 4.2 or newer. The name for this setting in the build settings editor is SDKROOT (Base SDK).
- The deployment target for your project must be iOS 3.1 or newer. The name for this setting is MACOSX_DEPLOYMENT_TARGET (Mac OS X Deployment Target).
- The compiler for your project must be the LLVM-GCC 4.2 compiler or newer, or the LLVM compiler (Clang) 1.5 or newer. The name for this setting is GCC_VERSION (C/C++ Compiler Version).
- You must ensure that any frameworks not available in your project’s deployment target are weakly linked, rather than required. See “Weak Linking to an Entire Framework” and “Linking Libraries and Frameworks” in Xcode Project Management Guide.

Issue

I'm still getting error on application startup:

2011-07-08 10:47:19.819 MyTestProject[47013:207] *** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x5a2aac0
2011-07-08 10:47:19.821 MyTestProject[47013:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x5a2aac0'
2011-07-08 10:47:19.822 MyTestProject[47013:207] Stack: (
    43358288,
    44516140,
    43367003,
    42829430,
    42826226,
    9319,
    1149252,
    1153359,
    1178942,
    1160439,
    1192408,
    47780220,
    42637468,
    42633384,
    1151521,
    1184626,
    9129,
    8997
)
terminate called after throwing an instance of 'NSException'

I get this when i try to run my application for iPad 3.2 Simulator. Any idea why?

p.s. Code works for iPad 4.2 and 4.3.


Solution

  • From the documentation for UIWindow, the property rootViewController is only available for iOS 4.0 and later (and, hence, so is setRootViewController):

    rootViewController

    The root view controller for the window.

    @property(nonatomic,retain) UIViewController *rootViewController

    Discussion

    The root view controller provides the content view of the window. Assigning a view controller to this property (either programmatically or using Interface Builder) installs the view controller’s view as the content view of the window. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.

    The default value of this property is nil.

    Availability

    Available in iOS 4.0 and later.

    This is why your app crashes on iOS 3.2, but not for iOS 4.2 and 4.3.