Search code examples
iosxcodeerror-handlingxcode4iad

suggestions on how i can resolve this "Semantic Issue" error


i have been trying to implement iAD into one of my view controllers and after writing the code for both the .h and .m file.... i get this semantic issue error:

@synthesize of 'weak' property is only allowed in ARC or GC mode

i specifically get this error right next to the @implementation of the .m file. any suggestions on how i can resolve this are much appreciated.

ALSO i was wondering whether it is ok to copy and paste this adbanner(Once its working) from this viewcontroller onto other view controllers withot re-coding ?

This is my code for iAD within the .h file

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>

@interface ViewController : UIViewController <ADBannerViewDelegate>
@property (weak, nonatomic) IBOutlet ADBannerView *banner;

@end

This is my code for iAD within the .m file

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
self.banner.delegate = self;
}

- (void) viewDidLayoutSubviews {
if (self.banner.bannerLoaded) {
    CGRect contentFrame = self.view.bounds;
    CGRect bannerFrame = self.banner.frame;
    contentFrame.size.height -= self.banner.frame.size.height;
    bannerFrame.origin.y = contentFrame.size.height;
    self.banner.frame = bannerFrame;
}
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:    (BOOL)willLeave
{
NSLog(@"bannerViewActionShouldBegin");
return YES;
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
NSLog(@"bannerViewDidLoadAd");
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
NSLog(@"didFailToReceiveAdWithError");
}

- (void)bannerViewActionDidFinish:(ADBannerView *)banner {
NSLog(@"bannerViewActionDidFinish");
}

@end

Solution

  • You could enable ARC by going to Edit pressing Refactor and Convert to Objective-C ARC.