                 alert.addAction(UIAlertAction(title: "cancel", style: UIAlertActionStyle.Default, handler: nil))
                 self.presentViewController(alert, animated: true, completion: nil)
             })
-
-        }
-        
-    }
-    
-
+            
+        }
+        
+    }
+    
+    
     
     //Update action
     @IBAction func Action(sender: UIButton) {
         //adding device name to the device object
         device = PIDevice(name: deviceName.text!)
         device.type = deviceType.text
-
-        
-        //adding device type to the device object. 
+        
+        
+        //adding device type to the device object.
         //NOTE: the type has to exist in the Presence Insights. Default types are : "Internal" and "External"
         
         //method to add encrypted data

        let alert = UIAlertController(title: titleInput, message: messageInput, preferredStyle: UIAlertControllerStyle.Alert)
        alert.addAction(UIAlertAction(title: "ok", style: UIAlertActionStyle.Default, handler: nil))
        self.presentViewController(alert, animated: true, completion: nil)

    }
    
    //function to check if both or none of the data value and key exist.
    func MissingText (value: UITextField, key : UITextField) -> Bool{
        if (key.text!.isEmpty && value.text!.isEmpty){
            return false
        }
        else if (key.text!.isEmpty || value.text!.isEmpty){
            return true
        }
        else{
            return false
        }

    }
    

    

    //initializing piAdapter object and PIdevice
    var piAdapter : PIAdapter!
    var device : PIDevice!
    
    
    @IBOutlet weak var deviceName: UITextField!
    @IBOutlet weak var datakey: UITextField!
