Question

I have a project working fine. I want to incorporate ads into it and make a free version. I've copied the project, renamed it and added iAd.framework. But it has caused SIGABRT on the run.

Debugging does not explain anything... it crashes on setting some VC properties from viewDidLoad method of the root VC. I do not think that it is relevant, but can provide details if you think otherwise.

Is there any trick in linking with iAd? Thanks for any help in advance!

EDIT: logs and some clarification added

2014-04-25 16:04:04.249 MyAppTEST[686:60b] -[MPViewController setSoundName:]: unrecognized selector sent to instance 0x16e43a30

2014-04-25 16:04:04.252 MyAppTEST[686:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MPViewController setSoundName:]: unrecognized selector sent to instance 0x16e43a30'

It complains on non-recognized selector (property setter, to be precise). BUT I did not change anything apart from linking iAd.framework. And if I remove this framework, it starts working fine again.

After some more tracing, I've figured out that, with iAd framework, [self.storyboard instantiateViewControllerWithIdentifier:@"MPPageContentController"]; returns a view controller of an improper type, but not nil!

MPViewController *pageContentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"MPPageContentController"];
if ([pageContentViewController isKindOfClass:[MPViewController class]]) {
    NSLog(@"OK");
}

The test is passed when iAd.framework is deleted, and fails otherwise! Any advice?

EDIT2: It is a real glitch! I've updated the test as following:

    MPViewController *pageContentViewController = (MPViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"MPPageContentController"];
    if ([pageContentViewController isKindOfClass:[MPViewController class]]) {
        NSLog(@"OK");
    } else {
        NSLog(@"%@", [pageContentViewController description]);
    }

And, in the case iAd is added to the project, the following is logged in the console: " MPViewController: 0xa63fd30 "

And I do see required MPViewController properties in the Variables View panel in Debug mode, though they are claimed as unrecognised... It's becoming more and more weird, but I'm running out of the ideas where to move forward! Any help?

Was it helpful?

Solution

The reason why your app crashed is that Apple has a class called MPViewController as you can see here.

Changing the ViewController's class name solves this issue.

I assume that iAd internally uses this class to display ads. The compiler decided to use Apples class instead of yours and therefore you got the does not respond to selector exception since Apple's MPViewController does not respond to that selector.


You can see that it is a good idea to conform to the Cocoa naming conventions and prefix your classes with 3 letters. I can't find a reference right now but I remember that they say (or said) that 2 letter prefixes are reserved for Apple classes.

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