发送“Class”的不兼容指针类型类型为“id”的参数
我收到警告:不兼容的指针类型在下面的“delegate:self”行中将“Class”发送到“id”类型的参数:
+ (SHKActionSheet *)actionSheetForType:(SHKShareType)type
{
SHKActionSheet *as = [[SHKActionSheet alloc] initWithTitle:SHKLocalizedString(@"Share")
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
as.item = [[[SHKItem alloc] init] autorelease];
as.item.shareType = type;
此警告位于 ShareKit 中,如果有人知道如何修复它,请告诉我!
I am receiving the warning Incompatible pointer types sending 'Class' to parameter of type 'id' in the line "delegate:self" below:
+ (SHKActionSheet *)actionSheetForType:(SHKShareType)type
{
SHKActionSheet *as = [[SHKActionSheet alloc] initWithTitle:SHKLocalizedString(@"Share")
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
as.item = [[[SHKItem alloc] init] autorelease];
as.item.shareType = type;
This warning is in ShareKit, if anyone knows how to fix it, please let me know!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您正在尝试在静态方法中传递 self 参数。这是不对的,因为静态方法中没有该对象的特定实例。使其成为非静态方法或将此类的某些实例作为委托传递。
You are trying to pass self parameter in a static method. It is not right as there is no particular instance of this object in static methods. Make it either non static method or pass some instance of this class as delegate.
使用静态类时,您可以手动消除警告:
When working with a static Class, you can manually get ride of the warning:
尝试使用 nil 而不是 self (xcode 4.2 iOS 5)。
Try using nil instead of self (xcode 4.2 iOS 5).