Question

In my AppController I have an if( _adView ) call. if( _adView ) is declared in MoPubManager.h. So, I added in #import "MoPubManager.h" in the top on my AppController. But, I'm getting an error that highlights the if( _adView ) call, and it states "Use of undeclared identifier." I though that importing the header would fix this. This is probably a really novice question, I'm still very new to Objective-C.

Was it helpful?

Solution

if _adView is a property of "MoPubManager.h", then you can access the

_adView

in any other controller by importing "MoPubManager.h" in that controller and create an object of that "MoPubManager.h"

like MoPubManager *obj = [MoPubManager alloc]init];

then you can access _adView by using obj._adview

Note:You can set the _adView with properties nonatomic or assign.If it is set to assign property you can change the value of _adView from any other controller

OTHER TIPS

Well, is there an Accessor for _adView, as declared in moPubManager.h?

I mean do you see something like... ?

(in moPubManager.h) @property (assign) id adView;

Also, always remember that variables "belong to" classes. There is no such C-like thing as "_adView" in your AppController file, simply because you imported it's header. What WOULD work is something like :

if ([moPub adView]) {... in your AppController

provided that :

  • Your AppController has defined a moPubManager instance (moPubManager* moPub)
  • adView has its accessors in place :

In moPubManager.h :

@interface moPubManager : NSObject
{
id _adView;
...
}

@property (assign) id _adView;

In moPubManager.m :

@implementation moPubManager

@synthesize adView=_adView;

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