0

我正在尝试在我的应用程序委托类中编写这些代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Let the device know we want to receive push notifications

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

    [FlurryAnalytics startSession:@"F9W2NQPF4Y587SM2Z3XU"];
    // Override point for customization after application launch.

    // Add the tab bar controller's view to the window and display.
    [self.window addSubview:tabBarController.view];
    [self.window makeKeyAndVisible];
    self.tabBarController.delegate=self;
    [self.tabBarController.tabBar setSelectedImageTintColor:[UIColor greenColor]];

    [window addSubview:OCRScreen.view];
    [window makeKeyAndVisible];
    [OCRScreen displayScreen];
    [OCRScreen.view removeFromSuperview];

    return YES;
}

但它在第一行出现错误后给了我错误。OCRAppDelegate.mm:错误:语义问题:无法使用“int”类型的右值初始化“UIRemoteNotificationType”类型的参数

当我将 .mm 更改为 .m 时,它不会给出此错误。请帮忙

4

1 回答 1

0

只需将第一行代码更改为:

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

现在它可以工作了。

于 2012-11-02T07:16:08.777 回答