What is a struct in iOS?
Structs are named types that allow for grouping items into one variable. A struct in Swift would look as follows:
struct
... [Show More] SomeStruct {
var name: String
var attribute: String
}
Struct vs Class
In Swift, structs are copied, and classes are referenced. Thus, they will be passed as values, not as references, in the case of large objects. Swift uses structs to improve performance, even with String and Array objects. Structs are preferable if
The purpose is to encapsulate a few data values.
The structure does not have to inherit values from other existing types.
What is a framework in iOS?
A framework is a "skeleton" that has been packed in a bundle, to be used and distributed within other applications. A framework can contain a wide variety of extra resources (images, strings that already have been localized, data files, UI objects, etc.). Unless a framework has been released to the public, it generally contains the .h files that you need to run it, as well.
library
Can be defined as the collection of functionality ready to be linked and used in an application. The framework can be a library, a set containing many libraries, a collection of scripts, or whatever you need to create your application. It is a more abstract term. If the candidate is asked for particular examples, a library could be a networking library.
How can you store information within your iOS app?
Keychain: This is thought to store sensitive data in a secure way (recurrent examples are logins and passwords).
SQLite database: If the data to be stored is complex or requires a huge amount of structured data, using an SQLite database is generally the best option.
Core Data: This is Apple's persistency framework. It's based on an object graph that describes the objects that should be saved. Then, you can directly work with these objects, and the framework takes care of saving it to a database.
Files: These can be directly saved in the application (for security reasons, an app can only access its own app container).
If you want to dive deeper, a potential candidate could discuss reasons for choosing SQLite over Core Data, for example. One reason could be that SQLite can be shared among different applications inother platforms, whereas Core Data is a framework exclusively available for Apple.
User Defaults: These can be used to persist a small amount of data. Typical examples are part of the configuration required to run the application.User defaults can persist the primitive types in iOS (String, Data, Number, Date, Array, and Dictionary).
What is a dictionary? Is it similar to other structures in other programming languages?
A dictionary stores associations between keys belonging to the same type, and values also belonging to the same type, in a collection with no defined ordering. Each value is associated with a unique key, acting as an identifier for that value within the dictionary. It is similar to what is known in other languages as a HashMap, with some subtle differences. [Show Less]