关于如何解决这个“语义问题”错误的建议

时间:2013-07-15 18:24:15

标签: ios xcode error-handling xcode4 iad

我一直在尝试将iAD实现到我的一个视图控制器中,并在为.h和.m文件编写代码之后....我得到了这个语义问题错误:

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

我特意在.m文件的@implementation旁边出现此错误。关于如何解决这个问题的任何建议都非常感谢。

ALSO 我想知道是否可以将此adbanner(一旦工作)从此viewcontroller复制并粘贴到其他视图控制器上并重新编码?

这是我在.h文件中的iAD代码

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

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

@end

这是我在.m文件中的iAD代码

#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

1 个答案:

答案 0 :(得分:1)

您可以通过转到编辑按重构并转换为Objective-C ARC来启用ARC。