UIRemoteNotificationType无效转换 [英] UIRemoteNotificationType invalid conversion
本文介绍了UIRemoteNotificationType无效转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的应用程序中使用这个标准的代码行:
I'm trying to use this fairly standard line of code in my app:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
但我收到以下错误:
error: invalid conversion from 'int' to 'UIRemoteNotificationType'
它的工作原理,如果我只使用一种通知类型,但每次失败,如果我尝试和使用多个。任何想法我做错了什么?
It works if I only use one of the notification types but fails every time if I try and use more than one. Any ideas what I'm doing wrong?
推荐答案
你可能使用Objective-C ++,
You're probably using Objective-C++, which implicit conversion from int
to an enum is disallowed.
尝试添加一个显式的投射:
Try to add an explicit cast:
[… registerForRemoteNotificationTypes:
(UIRemoteNotificationType)(UIRemoteNotificationTypeAlert | …)];
这篇关于UIRemoteNotificationType无效转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文