0

I am trying to save UISwitch results and using them to populate the "channels" for Parse.com push notifications. I followed the Parse Guide but I am getting a SIGABRT everytime I try and click the save button which saves the values of the switch. Any help is much appreciated

@IBAction func Save(sender: AnyObject) {

    if Athletics.on{
        let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.addUniqueObject("Athletics", forKey: "channels")
        currentInstallation.saveInBackground()
    }else{let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.removeObject("Athletics", forKey: "channels")
        currentInstallation.saveInBackground()
    }


    if Academics.on{
        let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.addUniqueObject("Academics", forKey: "channels")
        currentInstallation.saveInBackground()
    }else{let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.removeObject("Academics", forKey: "channels")
        currentInstallation.saveInBackground()
    }

    if LinkCrew.on{
        let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.addUniqueObject("LinkCrew", forKey: "channels")
        currentInstallation.saveInBackground()
    }else{let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.removeObject("LinkCrew", forKey: "channels")
        currentInstallation.saveInBackground()
    }

    if Events.on{
        let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.addUniqueObject("Events", forKey: "channels")
        currentInstallation.saveInBackground()
    }else{let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.removeObject("Events", forKey: "channels")
        currentInstallation.saveInBackground()
    }

    if Parents.on{
        let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.addUniqueObject("Parents", forKey: "channels")
        currentInstallation.saveInBackground()
    }else{let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.removeObject("Parents", forKey: "channels")
        currentInstallation.saveInBackground()
    }

    if Day1Day2.on{
        let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.addUniqueObject("Day1Day2", forKey: "channels")
        currentInstallation.saveInBackground()
    }else{let currentInstallation = PFInstallation.currentInstallation()
        currentInstallation.removeObject("Day1Day2", forKey: "channels")
        currentInstallation.saveInBackground()
    }


}
  • To identify which statement creates the error, set an exception breakpoint: In the breakpoint navigator of Xcode, click the plus sign down left and choose "Add exception breakpoints...", then hit return. Run your app, and it will stop at the problematic instruction. – Reinhard Männer Jan 27 '16 at 06:20
  • Why not update all the channels then save once at the end... – Wain Jan 27 '16 at 08:04

1 Answers1

1

The problem is not with your code, it's with your main.storyboard. The SIGABRT error shows when a storyboard element is connected to some other element or outlet which does not exist anymore.

To fix this error:

  1. Go to your main.storyboard
  2. Click on one of your elements (e.g. UILabel, etc)
  3. Click the connections inspector (looks like arrow in a circle)
  4. See if it's connected to something that doesn't exist and delete it/them
  5. Do steps 2 to 4 with all your elements
Cobie Fisher
  • 713
  • 2
  • 8
  • 18