Swi Interview Questions
iOS supports the SBJson framework. The SBJson framework adds more control and
flexibility to the JSON handling process. It is a well designed and extremely adaptable
framework that allows APIs (Application Programming Interfaces) to function in a
variety of ways. SBJSON is one of the many open-source JSON parsers or generators
created with Objective-C. These allow you to use JSON easily when coding Objective-
C apps.
14. What is the use of the "mutating" keyword in ios Swi ?
Ios Swi structs are immutable since they are of the value type. Other variables, for
example, cannot modify the values of structure at any point in time. Only the
"mutating" keyword is necessary to change the values of self variables within the
function of the structure. Let us take the following code snippet for example:
We get a compile-time error when we try to alter the value of variable "foo" inside a
function declared in the struct itself.
As a result, we will need to create a mutating function to update the value inside the
structure. As a result, the correct code is:
struct demoStruct {
var foo: String = "Initial String"
mutating func transformString() {
foo = "Transformed String".
}
}
15. What do you understand about protocols in ios Swi ?
Page 16
© Copyright by Interviewbit
struct demoStruct {
var foo: String = "Initial String"
func transformString() {
foo = "Transformed String".
//The above results in a compile time error: Cannot assign to property: 'self' is immut
//We need to mark the method 'mutating' to make 'self' mutable.
}
}