iOS Technology interview 04: Data storage

Source: Internet
Author: User

    1. If you need to increase the number of fields in the database how to implement, if you do not use coredata ?

Writing SQL statements to manipulate fields in the original table

1> Add Table field

ALTER table name ADD COLUMN Name field type;

2> Delete a table field

ALTER Table name DROP COLUMN field name;

3> Modifying a table field

ALTER table name RENAME column Old field name to new field name;

    1. How is SQLite data storage used?

1> add SQLite Dynamic Library:

2> Import Primary header file: #import <sqlite3.h>

3> using C language functions to create \ Open database, write SQL Statements

    1. A simple description of the client's caching mechanism?
      1. The cache can be divided into: memory data cache, database cache, file cache
      2. Every time I want to get the data,

1> detect if there is no cache in memory first

2> re-detect local cache ( database \ file )

3> Final Send network request

4> caches the network data returned by the server (memory, database, file) for the next read

    1. Do you implement too many threads of Core Data ? nspersistentstorecoordinator,nsmanagedobjectcontext and Which of the nsmanagedobject need to be created or passed in the thread? What kind of strategy do you use to achieve this?

1> CoreData is an encapsulation of the SQLite Database

nsmanagedobjectcontext in 2> coredata is unsafe in multiple threads

3> If you want to have multi-threaded access to coredata , the best approach is to have a thread a nsmanagedobjectcontext

4> each nsmanagedobjectcontext Object instance can use the same Nspersistentstorecoordinator instance because Nsmanagedobjectcontext will lock the nspersistentstorecoordinator before he uses it .

5 What is data persistence?

Plist, preferences, key-value archiving, Sqlite3,core data five. The previous 4 kinds, all just save OC type Object data, for example: NSNumber nsstring nsdata nsarray nsdictionary, and database, first is check whether the library, no then create a library,

then create the table inside the library, and then make the specific data store in the table , finally to close the database, the database is generally written in C, but Apple he has a library of his own, called Fmdb, is the OC version,

used to more face objects, but also after the C package, the first 4 types are ordinary object type, and core data is not, can be stored in a wide range, but not very good operation, poor stability, not a library, just a file

6 How is data transmitted, and what are the ways?

block, notification, agent, attribute, Singleton, etc.

iOS Technology interview 04: Data storage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.