I am implementing an UIAlertView, need it to run on iOS7. The code bellow works, but my question is about the behaviour of the **alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int)** function. 

I have a println("button index clicked (buttonIndex)") I am using to print what button has been clicked. Buttons are working fine, printing 0 and 1.

But also when the alertView initiates I get a 0 printed. Is that how is suppose to work? Or there is something wrong here?

> 
> UPDATED CODE
> 
> 
> 

```
        @IBAction func purgeDatabase() {

    // fetch request
    let fetchRequest = NSFetchRequest(entityName: "ConcreteBagEntity")
    var error : NSError?

    // execute fetch request
    if let fetchResults = self.managedObjectContext!.executeFetchRequest(fetchRequest, error: &error) as? [ConcreteBagEntity] {
        if error != nil{
            return
        }

        // if results are found
        if fetchResults.count != 0 {

            let purgeAlertController = UIAlertView(title: "Before you go ahead", message: "You are about to delete all your previous quotes. Are you sure you want to go ahead?", delegate: self, cancelButtonTitle: "Cancel")
            purgeAlertController.addButtonWithTitle("Ok")
            purgeAlertController.show()

        }// END IF FETCH != 0
        else{
            alertViewLaunch("Looks like there is nothing here to delete")
        }
    }//END FETCH REQUEST
}//END IBACTION

func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int) {
    println("button index clicked -> \(buttonIndex)")
    if buttonIndex == 1 {
        purgeAllData()
    }
}

```