Question

How would you write a universal app that uses classes introduced in iPhone OS 3.2, such as UIPopoverController and UISplitViewController? On Jeff LaMarche's blog about this, Ole provides a method for instantiating these objects; you would instantiate a UIPopoverController like so: [NSClassFromString(@"UIPopoverController") alloc].

This is fine for instantiating these classes in code but what about protocols and their methods? My iPad app uses a UISplitViewController and has a class that needs to conform to the UISplitViewControllerDelegate and UIPopoverControllerDelegate. How would you declare this? And how would you work with a method such as the following?

- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc

where the method call requires UISplitViewController to be passed in?

Was it helpful?

Solution 2

And, just like that, I see that this isn't a problem if you weak-link the UIKit framework. I found this right here on Stack Overflow.

OTHER TIPS

You can leave it there, since these UISplitViewController* etc only serves as a type for the compiler to do type-checking (unlike [UISplitViewController alloc] which an actual symbol needs to be linked).

Add a @class UISplitViewController, UIPopoverController; at the start of the file if it doesn't compile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top