无法使用类型为int的rvalue初始化UIRemote NotificationType类型的参数

时间:2011-12-14 09:59:03

标签: ios ios5 push-notification apple-push-notifications

当我使用[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];注册远程推送通知时,会发生错误cannot initialize a parameter of type 'UIRemoteNotificationType' with an rvalue of type 'int',有人知道为什么吗?谢谢。

我的项目环境:Xcode 4.2 + iOS 5.

1 个答案:

答案 0 :(得分:14)

您应该明确地将其强制转换为UIRemoteNotificationType

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationType)(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];