Thursday, August 24, 2017

Swift + AppDelegate

 var window: UIWindow?
    var navigationC: UINavigationController?
//    var loginVC:LoginVC!
    var welcomeVC:WelcomeVC!

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
            welcomeVC = WelcomeVC(nibName: "WelcomeVC", bundle: nil)
            self.navigationC  = UINavigationController(rootViewController: welcomeVC!)
        self.window?.rootViewController = navigationC
        self.navigationC!.setNavigationBarHidden(true, animated: true)
        self.window?.backgroundColor = UIColor.white
        self.window?.makeKeyAndVisible()
        return true

}

Swift + XCode Settings

When Installing pod then following setting require

User Header Search Paths : "${PODS_ROOT}/"

Swift+GeneralSearchDataFromTableView

  @IBAction func searchFilter(){
        var predicate = String()

        
        if (txtSearch.text == "") {
            articalData = articalGlobalData.mutableCopy() as! NSMutableArray
        }else{
            predicate = String(format: "SELF['article_name'] contains[c] '%@'", txtSearch.text!)
            print(predicate)
            
            let myPredicate:NSPredicate = NSPredicate(format:predicate)
            let temp = self.articalGlobalData.mutableCopy() as! NSArray
            self.articalData = (temp.filtered(using: myPredicate) as NSArray).mutableCopy() as! NSMutableArray
            
            
        }
        
        if articalData.count == 0 {
            lblNoArtical.isHidden = false
            tableViewArticalList.isHidden = true
        }
        else{
            tableViewArticalList.isHidden = false
            lblNoArtical.isHidden = true
        }
        tableViewArticalList.reloadData()


    }

Swift + GeneralTableView

  func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
       return self.patientData.count
    }

  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
            let identifier = "patientInfoCell"
            
            var cell = tableView.dequeueReusableCell(withIdentifier: identifier) as? PatientInfoTableVC
            
            if cell == nil {
                let nib  = Bundle.main.loadNibNamed("PatientInfoTableVC", owner: self, options: nil)
                cell = nib?[0] as? PatientInfoTableVC
            }
            cell!.selectionStyle = .none;
            return cell!
}

 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
            return 55.0
    }



  func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
   
let editAction:UITableViewRowAction = UITableViewRowAction(style: .normal, title: "Edit") { (action:UITableViewRowAction, indexPath:IndexPath) in
                
                self.patientID = (self.patientData[indexPath.row] as AnyObject).value(forKey: "patient_id") as? String
               
            }
            editAction.backgroundColor = UIColor.init(red: 108.0/255.0, green: 110.0/255.0, blue: 112.0/255.0, alpha: 1.0)
            
            let deleteAction:UITableViewRowAction = UITableViewRowAction(style: .normal, title: "Delete") { (action:UITableViewRowAction, indexPath:IndexPath) in
                print("Delete Clicked")
            }
            deleteAction.backgroundColor = UIColor.init(red: 85.0/255.0, green: 198.0/255.0, blue: 227.0/255.0, alpha: 1.0)
            return [editAction,deleteAction]
}

 func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
        

    }