Sunday, February 27, 2022

What are entitlements?

Ans:

What are Bundle Identifier and App Id ? What is difference between them?

 Ans:

What is Code Signing Request process?

 Ans:

Explain about certificates and provision profiles?

 Ans : 


Certificates - This is a cryptographic certificate granted to you by Apple.  It works just like SSL where you get a certificate signed by an authority.  Apple signs the private key that you use to sign different pieces of your application.  Different certificates create different types of trust.  Some allow you to sign and submit your application for the App Store, while others allow your application's web server to send push notifications to users via APNS.  In the latter case, for instance, Apple uses this certificate to trust the web server sending the push notification.  Otherwise, it would be easy for an attacker to spoof a valid push notification and spam users.  The most common certificate you would create signs the key you use to deploy your application to a device or submit it to the App Store.

When you create a certificate through Apple's developer portal, you have to create your key pair and send a "Certificate Signing Request," which at first is likely pretty confusing to developers just trying to see their application run on a device.
If you visit the developer portal, you'll find you can create certificates for Development or Distribution.  These certificates are rooted to different authorities, so that the two worlds are never confused (though all iOS devices trust both in a seemingly equal fashion).
Provisioning Profiles - Probably the most confusing component in the system, a provisioning profile indicates the devices for which an application is correctly signed.  If you visit the developer portal, you'll notice you can create two types (again called Development and Distribution).  Provisioning profiles say "applications with this Identifier signed with this Certificate's private key are okay to run on these devices."  Now that you know a provisioning profile is tied to a certificate, you can see why you have to decide whether to create a Development or Distribution profile.  Development profiles are limited to 100 devices.  Distribution profiles can either be Ad-Hoc or App Store distribution profiles.  I am not sure whether Ad Hoc profiles have device limits.
You might ask, then, why not always use a Distribution profile?  It can deploy to an unlimited number of devices, and is still attached to a certificate owned by the developer.  Another piece of Apple's security puzzle are Entitlements.  In an iOS application's bundle, you'll find Entitlements.plist, which is a list of capabilities that an application wants.  When signing your application using a certificate intended for distribution, Xcode (really the signing utility) will not allow an entitlement with get-task-allow set to YES.  This is because get-task-allow is what allows a debugger to connect to a process, and Apple doesn't want that happening on apps meant for distribution.


Short Ans : 

1. A Certificate authenticates you as an entity. It can represent you as an individual, or your company.
2. The Identifier is a unique ID for your mobile app.
3. A provisioning profile associates your certificate with the App ID. It is the link between #1 and #2 above.

Saturday, February 26, 2022

Describe application states in iOS and also app lifecycle?

Ans:

Application States:

1. Not running
2. Inactive
3. Active
4. Background
5. Suspended


1. Not running:
Application is not yet all start by system or system also terminate app and move to not running state.

2. Inactive:
Application is in foreground but not receiving any events from the app.
Ex: Phone call, Message or Notification is received by system.

3. Active:
Application is in foreground and also receiving events from app.
This is normal state of an application.

4. Background:
Application is in background and also executing the code.

5. Suspended:
Application is in background. but not executing the code.



Application Lifecycle Methods:

1. application:WillFinishLanuch:WithOptions
2. application:DidFinishLanuch:WithOptions
3. application:WillEnterForeground:
4. application:DidBecomeActive
5. application:WillResignActive
6. application:DidEnterBackground
7. application:WillTerminate

Tuesday, February 22, 2022

How to unwrap optionals?

To bring outside the associate type value from optional is called optional binding or unwrap optional.

we can do optional binding in 5 ways.

1. if let
2. guard let 
3. nil coalescing operator
4. optional chaining
5. explicit unwrap optionals



What will happen when we change singleton class to structure?

Only classes can be singletons in Swift.

Structures are value types, and copies are created every time, you pass a value to a function or a type. So due to this it will create multiple copies. But according to Singleton design pattern, there should be only one global instance for a class.

This clearly defeats the purpose of singletons.


  

Monday, February 21, 2022

What are different access controls in swift language?

Ans : 


To access the members inside an entity in a controlled manner,
we use the Access Controls
There are totally 5 different access specifiers.

1. open 
2. public
3. internal (default)
4. fileprivate
5. private

1. open -
Enables to access members of a module outside. 
Enable to subclass and override the classes in outside module as well.

2. public -
Allows us to subclass or override from within module in which it defined. 
But outside module, just we can utilize the functionality as it is without overriding.

Note:
So open class and class members can be accessible and overridden in which it is defined
and also in which module it is imported. public class and class members can be accessible
and overridden only in which it is defined.

3. internal -
Internal classes and members can be accessed anywhere within the same 
module(target) they are defined. 
You typically use internal access when defining an app’s or a framework’s internal structure.

4. fileprivate - 
Restricts the use of an entity to its defining file. It is used to hide
implementation details when details are used in entire file. fileprivate method is only 
accessible from that swift file in which it is defined.

5. private -
Restricts the use of an entity to the enclosing declaration and to extension
 of that swift file or class. It is used to hide single block implementation. private entity
 can be accessible in swift 4 but it gives error in swift 3.