I have implemented iAds into my app successfully in one particular view controller, and I want to put them in many of my other view controllers. It seems redundant to write the same iAd code over and over each again for each view controller. I want to be able to put all this code for iAds in one class and just call it whenever I need it. So I have heard of things called helper classes and class methods(+) but I am not sure if this what I need. Can anyone lead me in the right direction? An example would be helpful.
Edit
I created a singleton class without a view controller and I think thats right. Anyways in the iAd implementation, there are many lines of code that include adding a subview such as
[self.view addSubview:adView];
The singleton is telling me that it does not recognize "view". So when I am calling the singleton from my other view controllers, do I need to pass the view to the singleton? Thank you
Your new class, the iAd singleton, does indeed not have a view; thus you cannot access one from there.
I would suggest that, rather than passing the view controller’s view to the iAd class, you have your VCs request the ad. Something like this:
I’m not sure if you want to change the ads for each VC or not; I just added that as an idea.