Can someone explain me why it shows error here. I follow the tutorial, but maybe in swift 2, it doesn't true if typing like this.
Asked
Active
Viewed 57 times
0
-
4For one thing, you are misssing `.Alert` in the beginning. Also Swift 2 came with a new syntax for options, now `[.Alert, .Badge, .Sound]`. is used. – Sulthan Dec 21 '15 at 16:38
-
@Sulthan - Why not post that as an answer? – Wez Dec 21 '15 at 16:39
-
1@Wezly I was looking for the duplicate. – Sulthan Dec 21 '15 at 16:40
-
Thank you @Sulthan , It worked. I have just learned swift 2. – Twitter khuong291 Dec 21 '15 at 16:42
2 Answers
1
You are probably following tutorial from older version of Swift. Since its growing really fast, I suggest following the newest tutorials. In Swift 2 you should use collection, not | binary operator. Like:
[UIUserNotificationType.Sound, UIUserNotificationType.Badge]

sunshinejr
- 4,834
- 2
- 22
- 32
-
1
-
2Despite missing `.Alert` - there is still nothing wrong with using the full reference. – Wez Dec 21 '15 at 16:57
0
Your problem is with the first UIUserNotificationType
, which is missing (I guess) the .Alert
part.

jcaron
- 17,302
- 6
- 32
- 46