Cannot reference a local function error in Xcode 6 beta 6

I have just updated to Xcode 6 beta 6 from beta 4 and I am receiving an error that I don’t understand.

I am getting the error ‘Cannot reference a local function from another local function’.

  • Why use required Initializers in Swift classes?
  • Custom dealloc and ARC (Objective-C)
  • Attach a PDF file to email - Swift
  • Xcode “Build and Archive” from command line
  • Swift 3 Core Data Delete Object
  • Open app in specific view when user taps on push notification with iOS Swift
  •         var alert = UIAlertController(title: "Start Over", message: "Are you sure you want to start over? This will erase your budget and all transactions.", preferredStyle: UIAlertControllerStyle.Alert)
        alert.addAction(UIAlertAction(title: "I'm sure!", style: UIAlertActionStyle.Default, handler:{ (ACTION :UIAlertAction!)in
        alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil))
        self.presentViewController(alert, animated: true, completion: nil)

    The error is on the resetView() line of code.

    2 Solutions Collect From Internet About “Cannot reference a local function error in Xcode 6 beta 6”

    The error message is very explicative.

    resetView is a local function and you cannot refer to it from another local function.

    In order to fix the issue move resetView outside of the local scope.

    Another solution is to make resetView a local closure variable instead of a local function. That way you don’t have to move it out of the scope where it is now.