2010-04-06 21 views
5
benim app bu kod oldukça standart hattını kullanmaya çalışıyorum

:UIRemoteNotificationType geçersiz dönüşüm

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

Ama takip hata alıyorum: Ben sadece birini kullanıyorsanız

error: invalid conversion from 'int' to 'UIRemoteNotificationType' 

Çalışıyor Birden fazla denemeyi ve kullanmayı denediğimde bildirim türlerinin her seferinde başarısız olur. Yanlış yaptığım herhangi bir fikrin var mı?

cevap

14

Muhtemelen Objecting-C++ kullanıyorsunuz, bu da int arasındaki örtük bir dönüşüme izin verilmiyor.

[… registerForRemoteNotificationTypes: 
    (UIRemoteNotificationType)(UIRemoteNotificationTypeAlert | …)]; 
4

Sen UIRemoteNotificationType olarak sonucu döküm zorunda:

(UIRemoteNotificationType)(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound) 

yöntemi beklediği var Bu şekilde.

+0

Bu doğruydu ama KennyTM'nin cevabını neden ayrıntıyı sağladığı için kabul ettim. Teşekkürler. –

1

kullanın bu:

açık döküm eklemeyi deneyin Bu ur sorunu çözecektir.

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