0

Already checked this question: Weak linking UIPopoverBackgroundView and already read: http://www.marco.org/2010/11/22/supporting-older-versions-of-ios-while-using-new-apis#fnref:1

I have a custom PopoverBackgroundView declared in a .h and implemented in a .m file. Then, in just one file, I instantiate it like this

    self.settingsPopover.popoverBackgroundViewClass = [CustomPopoverBackgroundView class];

I´ve tried doing it like marco says in the link above:

if ([UIPopoverBackgroundView class] != nil) {
    self.settingsPopover.popoverBackgroundViewClass = [CustomPopoverBackgroundView class];
}

But I get the same launch error when I run in a 4.3 ipad simulator

dyld: Symbol not found: _OBJC_CLASS_$_UIPopoverBackgroundView

My base sdk is IOS 5.1, and my target deployment is 5.1 as well. Im using LLVM compiler 4.0.

Any ideas? Thanks a lot!

Community
  • 1
  • 1
pdrcabrod
  • 1,467
  • 1
  • 14
  • 22

1 Answers1

1

Have you tried using respondsToSelector with the relevant UIPopoverController setBackgroundViewClass method? Remember that properties automatically generate setter and getter methods that you can use in addition to the normal property syntax.

The reason why you're still getting linker errors is because you're still trying to call a method on that class, which doesn't exist.

If it's a case that the entire class doesn't exist, Apple recommends using NSClassFromString(@"UIPopoverController") and checking if the returned result is nil.

  • I havent any properties. The problem is that the app crashes before it can even reach my code. By setting UIkit as optional it works, but i dont want to do that – pdrcabrod Sep 18 '12 at 09:42
  • I know you haven't added any properties. What I mean is that by -using- a property in a class that doesn't exist, that's why it crashes. By verifying if the class exists via NSClassFromString before you use it, your application won't crash. –  Sep 18 '12 at 11:24