0

Please don't mark my question as duplicated even if it looks like answered many times. I really have a problem with "ViewController has no initializers", using CoreBluetooth

I found many similar problems here on stackoverflow (like: Class 'ViewController' has no initializers in swift) but the solution always was unwrapping an optional.

Here I tried to unwrap CBCentralManager object and CBPeripherial object as well but it didn't help. here's a screenshot:

enter image description here

smyslov
  • 1,279
  • 1
  • 8
  • 29
Bart
  • 21
  • 5
  • 1
    Can you also paste your code directly here. – Abhinav Sep 17 '15 at 08:48
  • You have explicitly unwrapped optional properties therefore you must create an initializer for your class or assign a default value. If you mark them as optional (?) then you don't need to have an initializer – Paulw11 Sep 17 '15 at 08:51
  • Hey Abhinav, here's my code: http://pastebin.com/EJ3tLGJn – Bart Sep 17 '15 at 08:54
  • Paulw11, I marked as optional as well but it didn't work. I'm not sure how to make an initializer for a ViewController class. – Bart Sep 17 '15 at 08:56
  • @Paulw11 Though conceptually the issue is same but I think OP has issue at different part of the code. Can we not allow community to provide answer here? – Abhinav Sep 17 '15 at 09:05
  • @Bart Thank you for sharing the code. Although despite your request, this question have been marked duplicate, here is how you can solve your issue. Your code has one uninitialized param `isOpen`. Change it to `var isOpen: Bool = true` and the compilation error should go away. – Abhinav Sep 17 '15 at 09:07
  • WOW! Thank you so much Abhinav! I would have never thought about it! Thanks again! – Bart Sep 17 '15 at 09:21

0 Answers0