XCode 5中的一个示例项目名为“Utility Application”。它有一个主视图和一个备用视图,并设置一个Info按钮将主视图翻转到备用视图。它使用viewcontroller委托和协议定义从翻转视图切换回主视图。在XCode 6中它不再存在。
当我在XCode 6中运行这个简单的XCode 5示例应用程序时,我会在下面的方法中收到警告:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showAlternate"]) {
[[segue destinationViewController] setDelegate:self]; //<<<< Here is where the warning appears
}
}
警告是:将'MainViewController * const_strong'发送到不兼容类型'id'的参数
这是什么?一个bug?该应用程序在模拟器和iOS设备上运行良好。以下是整个代码。任何帮助将不胜感激。**// MainViewController.h
#import "FlipsideViewController.h"
@interface MainViewController : UIViewController <FlipsideViewControllerDelegate>
@end
// MainViewController.m
#import "MainViewController.h"
@interface MainViewController ()
@end
@implementation MainViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Flipside View
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showAlternate"]) {
[[segue destinationViewController] setDelegate:self]; //<<<< Here is where the warning appears
}
}
@end
// FlipsideViewController.h
#import <UIKit/UIKit.h>
@class FlipsideViewController;
@protocol FlipsideViewControllerDelegate
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller;
@end
@interface FlipsideViewController : UIViewController
@property (weak, nonatomic) id <FlipsideViewControllerDelegate> delegate;
- (IBAction)done:(id)sender;
@end
// FlipsideViewController.m
#import "FlipsideViewController.h"
@interface FlipsideViewController ()
@end
@implementation FlipsideViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Actions
- (IBAction)done:(id)sender
{
[self.delegate flipsideViewControllerDidFinish:self];
}
@end**
答案 0 :(得分:0)
您可能已经想到了这一点......只是想发布一个链接,以便找到那些绊脚石:getting a warning setting up delegate for a custom protocol