Search Your Question

What is localization?

Ans : 

Localization is simply the process of translating your app into multiple languages. However, before you can localize your app, you first need to internationalize it. Internationalization is the process of making your app able to adapt to different languages, regions, and culture. Simple enough, I guess.

So after opening app, we can detect user's locale and change app's language,time accordingly.


Difference Between Inheritance And Extensions?

Ans : 

When to use extension : 
Are you adding general-purpose functionalities that should be available to every UITextField? If so, make an extension. All UITextField instances can call the new methods.

When to use inheritance : 
Are you adding functionality that should be restricted to special instances of UITextField that you would identify precisely? If so, make a subclass. Only the instances of the subclass can use the new methods.

Another diff :

In extension, there is no any specific name of extension in swift, but while subclassing there is another name of subclass.

In extension, we can not add variables (fields), in subclass it is possible to declare variables.


How To Access AppDelegate Methods In Other Class?

Ans : 

let appDelegate: AppDelegate? = UIApplication.shared.delegate as? AppDelegate
appDelegate?.application(UIApplication.shared, didFinishLaunchingWithOptions: nil)

You can make your custom method any called from viewcontroller like :

let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.anyAppDelegateInstaceMethod()

But above is only possible in iOS 10.0 or newer version.

Difference Between If Let And Guard Let?

Ans : 

Basic Difference :

Guard let 

Early exist process from the scope
Require score existing like return, Throw etc.
Create a new variable those can be access out the scope.

if let 

Can not access out the scope.
no need to return statement. But we can write

Note : Both are used to unwrapped the Optional variable.


Guard let


  • A guard statement is used to transfer program control out of a scope if one or more conditions aren’t met. 
  • The value of any condition in a guard statement must be of type Bool or a type bridged to Bool. The condition can also be an optional binding declaration.


guard condition else { //Generally return }
func submit() {
guard let name = nameField.text else {
    show("No name to submit")
    return

}

If let
  • Also popular as optional binding 
  • For accessing optional object we use if let
if let roomCount = optionalValue {
        print("roomCount available")
} else {
       print("roomCount is nil")

}



Q. return is mandatory in guard let statement ?
A. Exit is mandatory in guard let statement. So return or throw is mandatory in guard let. Otherwise it gives compile time error.


Difference Between UIWindow And UIView?

Ans :

Windows do not have any visible content themselves but provide a basic container for your application’s views. 

Views define a portion of a window that you want to fill with some content. 

Note : Typically, there is only one window in an iOS application.