 
     
     override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
-        let cell = tableView.dequeueReusableCellWithIdentifier("AlarmCell", forIndexPath: indexPath) as! UITableViewCell
+        var cell = tableView.dequeueReusableCellWithIdentifier("AlarmCell", forIndexPath: indexPath) as! UITableViewCell
+        
+            //cell = UITableViewCell(style: .Subtitle, reuseIdentifier: "AlarmCell")
+            cell.tag = indexPath.row
+            let ala = Alarms.sharedInstance[indexPath.row] as Alarm
+            cell.textLabel?.text = ala.timeStr
+            cell.detailTextLabel?.text = ala.title
+        
+        
 
         // Configure the cell...
-        let ala = alarms[indexPath.row] as Alarm
+        
         let sw = UISwitch(frame: CGRect())
-        cell.tag = indexPath.row
+        //tag is used to indicate which row had been touched
+        
         sw.tag = indexPath.row
-        cell.textLabel?.text = ala.title + "          " + ala.timeStr
-        
-        
+
         //cell.detailTextLabel?.text = ala.time
         cell.backgroundColor = UIColor(red: 0.8, green: 0.8, blue: 0.8, alpha: 1.0)
         sw.addTarget(self, action: "SwitchTapped:", forControlEvents: UIControlEvents.TouchUpInside)


import UIKit
import MediaPlayer
var alarms: [Alarm] = [Alarm]()

class MainAlarmViewController: UITableViewController{
    
    
    
    /*let alarm = Alarm(title: "test", timestr: "", time: NSDate())
    
    @IBAction func AddAlarm(sender: AnyObject) {
        var timePicker = UIPickerView()
        //timePicker.dataSource = self
        //timePicker.delegate = self
        alarms.append(alarm)
        tableView.reloadData();
        
    }*/
    

    override func viewDidLoad() {
        super.viewDidLoad()

        {
            println("switch off")
            sender.superview?.backgroundColor = UIColor(red: 0.8, green: 0.8, blue: 0.8, alpha: 1.0)
            Alarms.sharedInstance[sender.tag].enabled = false
            //UIApplication.sharedApplication().cancelLocalNotification(UIApplication.sharedApplication().scheduledLocalNotifications[sender.tag] as! UILocalNotification)
            UIApplication.sharedApplication().scheduledLocalNotifications = nil
            for alarm in Alarms.sharedInstance{
                if alarm.enabled{
                alarmDelegate.setNotificationWithDate(alarm.date)
                }
            }
            
