Tuesday, 16 July 2019

What is the difference between protocol, extension and category in IOS development? And how to use them appropriately?


Protocols


A protocol declares a programmatic interface that any class may choose to implement.


A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. Protocols are like Interfaces, that provide some methods that the class conforming must implement.


Uses:
A common use case is to let you alter the behavior of certain classes without the need to subclass them.
Eg: UITableViewDelegate, UITableViewDataSource




Extension


Extensions add new functionality to an existing class, structure, enumeration, or protocol type. This includes the ability to extend types for which you do not have access to the original source code (known as retroactive modeling).


Extensions are similar to categories in Objective-C. (Unlike Objective-C categories, Swift extensions do not have names.)


Uses:


Categories are a way to modularize a class by spreading its implementation over many files. Extensions provide similar functionality.


One of the most common uses of categories is to add methods to built-in data types like NSString or NSArray. The advantage of this is that you don’t have to update the existing code to use a new subclass

Thursday, 4 July 2019

IOS APP DATABASE INTEGRATION USING FMDB

STEP ONE CREATE DATABASE AND TABLE

COPY DATA BASE INTO PROJECT



// util.copydataBase("Sata.db") Write this Line IN APPdelegate file after Downloading Zip File and copy into your project

https://drive.google.com/file/d/1nptZ8mE6jc-iCC-EjEtqu5NSVHfAm0SE/view?usp=sharing


Set Below code in your viewcontroller where you want to save data

 @IBAction func SaveClick(_ sender: UIButton)

    {
        let modelinfo = SignuModel(fname: txtFname.text!, lname: txtLname.text!, dob: txtDOB.text!, email: txtEmail.text!)
        let isSave = DBHelper.getinstance().savedata(modelinfo)
        print(isSave)
    }