【发布时间】:2011-09-15 22:24:14
【问题描述】:
我收到有关将*const _strong 传递给类型id 的语义问题的警告,并且无论我如何更改似乎都无法修复它。
我目前有两个视图,并且已经编写了这段代码。在 iPadSpeckViewController.m 中,这里是应该在视图之间切换的方法:
-(IBAction) touchProducts {
ProductsViewController *controller = [[ProductsViewController alloc]
initWithNibName:@"Products" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
controller.delegate = self;
[self presentModalViewController:controller animated:YES];
}
对于 ProductsViewController.h:
@interface ProductsViewController : UIViewController {
id<ProductsViewControllerDelegate> delegate;
}
@property(nonatomic, retain)
IBOutlet id<ProductsViewControllerDelegate> delegate;
ProductsViewController.m 包含:
@synthesize delegate;
但是观点并没有改变……有什么想法吗?
编辑: 这是确切的警告,因为它出现在“controller.delegate = self;”行在 iPadSpeckViewController.m 中:
/Developer/iPadSpeckApp/iPadSpeckApp/iPadSpeckAppViewController.m:17:27:{17:27-17:31}: warning: passing 'iPadSpeckAppViewController *const __strong' to parameter of incompatible type 'id<ProductsViewControllerDelegate>' [3]
【问题讨论】:
-
您确定您的 ProductsViewController.h 文件“了解” ProductsViewControllerDelegate 协议吗?换句话说,你的头文件开头有
#import "ProductsViewControllerDelegate.h"语句吗? -
是的。 iPadSpeckViewController.h 和 ProductsViewController.m 都导入了 ProductsViewController.h
-
请发布您遇到的错误的确切文本。另外,标记错误发生的行,这样我们就可以准确地看到编译器在抱怨什么。
标签: iphone objective-c delegates uiviewcontroller