注册多个远程通知类型时出错

Aja*_*jay 2 iphone ios ios5 xcode4.2

当我注册多种通知类型时,XCode让我疯狂:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge]; 
Run Code Online (Sandbox Code Playgroud)

要么

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge)]; 
Run Code Online (Sandbox Code Playgroud)

抛出错误而不是警告:

错误:语义问题:无法使用类型为'int'的rvalue初始化'UIRemoteNotificationType'类型的参数

即使这是每个人都使用的同一条线(甚至是他们演示中的Apple).我正在使用iOS 5 SDK(iOS 5发布后出现的第一个)和XCode 4.2.该项目是一个较旧的项目(XCode 3和iOS 4),正在升级并针对iOS 5.

Leo*_*Qiu 5

我也有这个问题.诀窍是如果此代码位于.mm文件(Objective C++)中,则会发生此错误.如果您没有使用任何C++功能,请将文件扩展名从.mm更改为.m,它将编译正常.