3

I've got Xcode 7.2 on a MacBook Air.
I'll directly show you the problem

My Problem:

in ViewController.swift:

let appdelegate : AppDelegate = UIApplication.sharedApplication().delegate as? AppDelegate

This line is giving me an error: Use of undeclared type 'AppDelegate'


In my AppDelegate.swift, the UIApplicationDelegate is named as "AppDelegate":
class AppDelegate: UIResponder, UIApplicationDelegate{

Still why does it show me this error.

This is just an example in this view controller. this same problem occurs in one more class (or file), BUT not in all classes (or files)

Solutions I've tried:

  • restarting, reinstalling Xcode.
  • rebooting my mac.
  • Deleting 'DerivedData' folder which is located in /Library/Developers/Xcode/.
illusion
  • 1,272
  • 11
  • 22
  • Possible duplicate of [Autocomplete in XCode not working as expected (from using other IDE's)](http://stackoverflow.com/questions/17717028/autocomplete-in-xcode-not-working-as-expected-from-using-other-ides) – Max MacLeod Nov 11 '15 at 13:00
  • The solution for the issue ain't working for me – illusion Nov 11 '15 at 13:09
  • You should try force casting it: `let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate` – pbush25 Nov 11 '15 at 17:08
  • if you cast it with as? you get back an optional, so you need do that: `let appdelegate : AppDelegate? = UIApplication.sharedApplication().delegate as? AppDelegate` – Tony J Stark Nov 11 '15 at 17:39
  • Not force casting not working. Getting the same error – illusion Nov 12 '15 at 03:32

0 Answers0