Thursday, May 19, 2016

Advantages of SQLite Database over File Storage

  • SQLite is an amazing library that gets embedded inside the application that makes use of. As a self-contained, file-based database, SQLite offers an amazing set of tools to handle all sorts of data with much less constraint and ease compared to hosted, process based (server) relational databases. A very powerful, embedded relational database management system.
  • If you want to query your data, store the data in structured manner you wil prefer SQLite
  • SQLite has higher performance
  • SQLite database can also be queried and the data retrieval is much more robust.
  • The android.database and android.database.sqlite packages offer a higher-performance alternative where source compatibility is not an issue.
  • Android-databases created in Android are visible only to the application that created them
  • There is no file parsing and generating code to write and debug.
  • Content can be accessed and updated using powerful SQL queries, greatly reducing the complexity of the application code.
  • Extending the file format for new capabilities in later releases is a simple as adding new tables or new columns to existing tables.
  • Diverse content which might otherwise be stored as a "pile-of-files" can be encapsulated into a single disk file.
  • The content can be viewed using third-party tools.
  • The application file is portable across all operating systems, 32-bit and 64-bit and big- and little-endian architectures.
  • The application only has to load as much data as it needs, rather than reading the entire application file and holding a complete parse in memory. Startup time and memory consumption are reduced.
  • Small edits only overwrite the parts of the file that change, not the entire file, thus improving performance and reducing wear on SSD drives.
  • Content is updated continuously and atomically so that there is no work lost in the event of a power failure or crash.
  • Applications can leverage the full-text search and RTREE capabilities that are built into SQLite.
  • Performance problems can often be resolved using CREATE INDEX rather than redesigning, rewriting, and retesting application code.
  • A federation of programs, perhaps written in different programming languages, can all access the same application file with no compatibility concerns.
  • Multiple processes can attach to the same application file and can read and write without interfering with each another.
  • Cross-session undo/redo can be implemented using triggers.
  • In many common cases, loading content from an SQLite database is faster than loading content out of individual files. See Internal Versus External BLOBs for additional information.
  • Content stored in an SQLite database is more likely to be recoverable decades in the future, long after all traces of the original application have been lost. Data lives longer than code.
  • No wheel reinventing
  • No socket and/or TCP/IP overhead.
  • In many cases at least 2-3 times faster then MySQL/PostgreSQL.
  • Sub-selects, Triggers, Transactions, Views.
  • Up to 2TB of data storage.  
  • Small memory footprint.
  • Self-contained: no external dependencies.
  • Atomic commit and rollback protect data integrity.
  • Easily movable database.
  • Security - Each user has their own completely independent database(s).     

Monday, May 16, 2016

Passing data with Unwind Segue in Swift Language – iOS 9

An unwind segue (sometimes called exit segue) can be used to navigate back through push, modal or popover segues (as if you popped the navigation item from the navigation bar, closed the popover or dismissed the modally presented view controller). On top of that you can actually unwind through not only one but a series of push/modal/popover segues, e.g. “go back” multiple steps in your navigation hierarchy with a single unwind action.
To enable the Unwind Segue you need to add some code first.
@IBAction func unwindToVC(segue: UIStoryboardSegue) {
You have to add this code in the view controller where you want to unwind (came back).

Unwind To View
Suppose you want to came back from second or third view to first view then you have to add the code in first view.
Then just connect any control(Which contains action) with the unwind segue.
Unwind SegueUnwind Segue
For check the particular view controller by unwind segue, use following code :
@IBAction func unwindToVC(segue:UIStoryboardSegue) {
    if(segue.sourceViewController .isKindOfClass(ViewController2))
        let alert = UIAlertView()
        alert.title = "UnwindSegue"
        alert.message = "Unwind from view 2"
    if(segue.sourceViewController .isKindOfClass(ViewController3))
        let alert = UIAlertView()
        alert.title = "UnwindSegue"
        alert.message = "Unwind from view 3"