Wednesday, 26 June 2019

Different iOS questions from different sites




Automatic, non automatic, retain, relese, setter, getter, synthesized

Delegates, protocols, categories and exhibition.



4. Differentiate ‘app ID’ from ‘bundle ID’. Explain why they are used.

5. Which are the ways of achieving concurrency in iOS?
The three ways to achieve concurrency in iOS are:

Threads
Dispatch queues
Operation queues

There are basically three ways of achieving concurrency in iOS:

threads
dispatch queues
operation queues
The disadvantage of threads is that they relegate the burden of creating a scalable solution to the developer. You have to decide how many threads to create and adjust that number dynamically as conditions change. Also, the application assumes most of the costs associated with creating and maintaining the threads it uses.

OS X and iOS therefore prefer to take an asynchronous design approach to solving the concurrency problem rather than relying on threads.

One of the technologies for starting tasks asynchronously is Grand Central Dispatch (GCD) that relegates thread management down to the system level. All the developer has to do is define the tasks to be executed and add them to the appropriate dispatch queue. GCD takes care of creating the needed threads and scheduling tasks to run on those threads.

All dispatch queues are first-in, first-out (FIFO) data structures, so tasks are always started in the same order that they are added.

An operation queue is the Cocoa equivalent of a concurrent dispatch queue and is implemented by the NSOperationQueue class. Unlike dispatch queues, operation queues are not limited to executing tasks in FIFO order and support the creation of complex execution-order graphs for your tasks.




7. Which is the framework that is used to construct application’s user interface for iOS?
The UIKit framework is used to develop application’s user interface for iOS. It provides event handling, drawing model, windows, views, and controls specifically designed for a touch screen interface.

8. Which is the application thread from where UIKit classes should be used?
UIKit classes should be used only from an application’s main thread.

9. Which API would you use to write test scripts to exercise the application’s UI elements?
UI Automation API is used to automate test procedures. JavaScript test scripts that are written to the UI Automation API simulate user interaction with the application and return log information to the host computer.


15. What is SpriteKit and what is SceneKit?
SpriteKit is a framework for easy development of animated 2D objects.

SceneKit is a framework inherited from OS X that assists with 3D graphics rendering.

SpriteKit, SceneKit, and Metal are expected to power a new generation of mobile games that redefine what iOS devices’ powerful GPUs can offer.



16. What are iBeacons?


20. Outline the class hierarchy for a UIButton until NSObject.
UIButton inherits from UIControl, UIControl inherits from UIView, UIView inherits from UIResponder, UIResponder inherits from the root class NSObject.



What is the purpose of the reuseIdentifier? What is the advantage of setting it to a non-nil value?



Consider the two methods below:

application:willFinishLaunchingWithOptions
application:didFinishLaunchingWithOptions
What is the usage of these methods and what is difference between them?

A) Both methods are present in the AppDelegate.swift file. They are use to add functionality to the app when the launching of app is going to take place.

The difference between these two methods are as follows:

application:willFinishLaunchingWithOptions—This method is your app’s first chance to execute code at launch time.
application:didFinishLaunchingWithOptions—This method allows you to perform any final initialization before your app is displayed to the user.


What are rendering options for JSONSerialization?

A) MutableContainers: Arrays and dictionaries are created as variable objects, not constants.
MutableLeaves: Leaf strings in the JSON object graph are created as instances of variable strings.
allowFragments: The parser should allow top-level objects that are not an instance of arrays or dictionaries.





Explain the difference between copy and retain?

Retaining an object means the retain count increases by one. This means the instance of the object will be kept in memory until it’s retain count drops to zero. The property will store a reference to this instance and will share the same instance with anyone else who retained it too. Copy means the object will be cloned with duplicate values. It is not shared with any one else.


What is method swizzling


What is a category and when is it used?

A category is a way of adding additional methods to a class without extending it. It is often used to add a collection of related methods. A common use case is to add additional methods to built in classes in the Cocoa frameworks. For example adding async download methods to the UIImage class.


What considerations do you need when writing a UITableViewController which shows images downloaded from a remote server?

This is a very common task in iOS and a good answer here can cover a whole host of knowledge. The important piece of information in the question is that the images are hosted remotely and they may take time to download, therefore when it asks for “considerations”, you should be talking about:

Only download the image when the cell is scrolled into view, i.e. when cellForRowAtIndexPath is called.
Downloading the image asynchronously on a background thread so as not to block the UI so the user can keep scrolling.
When the image has downloaded for a cell we need to check if that cell is still in the view or whether it has been re-used by another piece of data. If it’s been re-used then we should discard the image, otherwise we need to switch back to the main thread to change the image on the cell.



What is a protocol, and how do you define your own and when is it used?



What is KVC and KVO? Give an example of using KVC to set a value.

What is KVC and KVO? Give an example of using KVC to set a value.

KVC stands for Key-Value Coding. It's a mechanism by which an object's properties can be accessed using string's at runtime rather than having to statically know the property names at development time. KVO stands for Key-Value Observing and allows a controller or class to observe changes to a property value.

Let's say there is a property name on a class:

@property (nonatomic, copy) NSString *name;
We can access it using KVC:

NSString *n = [object valueForKey:@"name"]
And we can modify it's value by sending it the message:

[object setValue:@"Mary" forKey:@"name"]


What is KVC and KVO? Give an example of using KVC to set value.

Key-Value-Coding (KVC) means accessing a property or value using a string. id someValue = [myObject valueForKeyPath:@”foo.bar.baz”];
Which could be the same as:
id someValue = [[[myObject foo] bar] baz];
Key-Value-Observing (KVO) allows you to observe changes to a property or value.
To observe a property using KVO you would identify to property with a string; i.e., using KVC. Therefore, the observable object must be KVC compliant.
[myObject addObserver:self forKeyPath:@”foo.bar.baz” options:0 context:NULL];





What is the Responder Chain?



How would you securely store private user data offline on a device? What other security best practices should be taken?

Again there is no right answer to this, but it's a great way to see how much a person has dug into iOS security. If you're interviewing with a bank I'd almost definitely expect someone to know something about it, but all companies need to take security seriously, so here's the ideal list of topics I'd expect to hear in an answer:

If the data is extremely sensitive then it should never be stored offline on the device because all devices are crackable.
The keychain is one option for storing data securely. However it's encryption is based on the pin code of the device. User's are not forced to set a pin, so in some situations the data may not even be encrypted. In addition the users pin code may be easily hacked.
A better solution is to use something like SQLCipher which is a fully encrypted SQLite database. The encryption key can be enforced by the application and separate from the user's pin code.
Other security best practices are:

Only communicate with remote servers over SSL/HTTPS.
If possible implement certificate pinning in the application to prevent man-in-the-middle attacks on public WiFi.
Clear sensitive data out of memory by overwriting it.
Ensure all validation of data being submitted is also run on the server side.





 What are Tuples in Swift?

Tuples are Temporary container for Multiple Values. It is a comma-separated list of types, enclosed in parentheses. In other words, a tuple groups multiple values into a single compound value.



Q13). What are the Control Transfer Statements in swift?
break, continue, fallthrough, return, throw


Q14). What are closures and write an example program for closure?
Closures are self-contained blocks of functionality that can be passed around and used in code.

var addClosure = { (a: Int, b: Int) in

return a + b

}

let result = addClosure(1,2)

print(result)





Q15). Briefly explain reference types and value types with examples?
Classes are reference types and Structures are value types. When a class is assigned to variable and copied only the reference to the original value are passed and so any consecutive changes to the assigned values will also affect the original value.

But in struct when it is assigned to another variable a copy is generated which will not have any effect on the original value when changed.


Q31). How to pass data between view controllers
Segue, in prepareForSegue method (Forward)
Delegate (Backward)
Setting variable directly (Forward)
Q36). Types of Dispatch Queues
Serial :execute one task at a time in the sequential order

Concurrent: execute one or more tasks concurrently.

Main dispatch queue: executes tasks on the application’s main thread.

Q37). key value coding(KVC) and key value observing (KVO)
Key-Value-Coding (KVC) : accessing a property or value using a string.

Key-Value-Observing (KVO) : observe changes to a property or value.

Q38). Application life cycle
application:willFinishLaunchingWithOptions
application:didFinishLaunchingWithOptions
applicationDidBecomeActive
applicationWillResignActive
applicationDidEnterBackground
applicationWillEnterForeground
applicationWillTerminate
Q39). Different states of application
Not running
Inactive
Active
Background
Suspended
Q40). View life cycle
loadView
loadViewIfNeeded
viewDidLoad
viewWillAppear
viewWillLayoutSubviews
viewDidLayoutSubviews
viewDidAppear
viewWillDisappear
viewDidDisappear
Q41). whats is delegate  and notification
Delegate: Creates the relationship between the objects. It is one to one communication.

Notification: These are used if an object wants to notify other objects of an event. It is one to multiple communication.

Q42). What is the significance of “?” in Swift?
The question mark (?) is used during the declaration of a property can make a property optional. If the property does not hold a value.

Q43).What are the Levels of Prority in QOS?
User Interactive
User Initiated
Utility
Background
Q44). How to write optional value in swift ?
An optional that can hold either a value or no value. Optionals are written by appending a ‘?’

Q45). How to unwrap the optional value in swift ?
The simplest way to unwrap an optional value  is to add a ‘!’ after the optional name. This is called “force unwrapping”.

Q46). Use of if -let statement in swift
By using if- let ,we can unwrap an optional in safe way, otherwise  nil it may crash the app sometimes.

Q47). What is id in Objective C?
id is a type of any data type. It specifies a reference to any Objective-C object .

Q48). What is Categories in Objective C?
Categories provide the ability to add functionality to an object without changing the actual object.

Q49). What is Extension in swift?
Extension add new functionality to an existing class, structure, enumeration, or protocol type. Extensions are similar to categories in Objective-C.

Q50). Define Class methods and instance methods .
An instance method  accessed an instance of the class

A class method accessed to the class itself.

Q51). How to add swift file to the existing Objective C project?
If you add a new swift file to the existing project xcode will ask you to add Objective-C bridging header.


Q53).How many ways constraints can create programmatically?
Three ways  to creating constraints programmatically :

 layout anchors
 NSLayoutConstraint class
 Visual Format Language.

Q54). Is it possible to create multiple storyboards in single project. If yes how to switch from one storyboard to another?
Yes, By using segue and Storyboard Reference we can  switch from one storyboard to another storyboard.


Q55). What is let and var in swift?
Let is  immutable variable or a  constant that means it cannot changed where as var is mutable variable meaning that it can be changed.

Q56). What is IBOutlet and IBAction in ios ?
Interface Builder outlet(IBOutlet) is a variable which is a reference to a UI component.

Interface Builder action(IBAction) is a function which is called when a specific user interaction occurs.

Q57). What is bundle in ios?
A bundle is a directory in the file system that contains the all executable code and related resources such as images and sounds together in one place.

Q58). when  will use deinit  in swift?
deinit can be used if you need to do some action or cleanup before deallocating the object.

Q59). what is the responsibility of URLSession?
URLSession is responsible for sending and receiving HTTP requests.

Q60). what are the types of URLSessionTask?
URLSessionDataTask
URLSessionUploadTask
URLSessionDownloadTask

Q61). Main difference between NSURLSession and NSURLConnection
NSURLConnection:

when our App goes to background mode or  not running  mode  using  NSURLConnection, everything we have received or sent were lost.

NSURLSession:

NSURLSession gives your app the ability to perform background downloads when your app is not running or app is suspended.


Q63). what is JSONSerialization ?
The  built in way of parsing JSON is called JSONSerialization and it can convert a JSON string into a collection of dictionaries, arrays, strings and numbers .

Q64). Difference between core  data and sqlite?
Core Data is a framework that can be used for managing an object graph. Core Data is not a database.Core Data can use a SQLite database as its persistent store, but it also has support for other persistent store types, including a binary store and an in-memory store. SQLite is a lightweight relational database.

Q65). Difference between Keychain and NSUserDefaults?
In Keychain: If user removed the app from device  the saved  UserName and Password still is there.

In NSUserDefaults: If user removed the app from device  the saved  UserName and Password  also removed.


Q66). what is app thinning. How to reduce app size?
App thinning is concept of reducing the app size while downloading.Using the below methods we can reduce the app size

App Slicing
Bitcode
On-Demand Resource

Q68). What are the types of certificates required for developing and distributing apps?
Development and distributing certificates.

Development certificate: used for development

Distribution certificates: used for submitting apps to app store or in house

Q69). what are binaries required to install  the app to device?
.ipa,

.app







Options: [] is an empty array returns nothing.
Whereas Options: [] can also be amend with:
  • NSJSONWritingOptions: for writing JSON data like.
    • NSJSONWritingOptions.NSJSONWritingPrettyPrinted: Specifies that the JSON data should be generated with whitespace designed to make the output more readable. If this option is not set, the most compact possible JSON representation is generated.
  • NSJSONReadingOptions: used when creating Foundation objects from JSON data.
    • NSJSONReadingOptions.MutableContainers: Specifies that arrays and dictionaries are created as mutable objects.
    • .mutableLeaves: Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString.
    • .allowFragments: Specifies that the parser should allow top-level objects that are not an instance of NSArray or NSDictionary.






https://www.gangboard.com/blog/ios-interview-questions-and-answers/


https://mindmajix.com/ios-development-interview-questions


https://www.macstadium.com/

https://portal.macstadium.com/tickets/78006



From Udemy


UI Ux difference

I Beacons





How do we do multi-threading in IOS?




How would you animate a view that has a constraint?






Discuss assign vs retain






Describe Managed Object Context


downloading images


Dynamic Dispatch?


Framework in IOS


layer objects


more layer/CALayer




app crash


MVC


class hierarchy


auto-release pool?


iBeacons


Define SpriteKit and SceneKit


Swift vs Objective-C?


app not in "running state"?


App States


Test Scripts


Threading


users interface


IOS App States


Present Modally


strong vs weak


Strong vs weak 2


reuse identifier?


static analyzer?


stride


Explain ~/Library~/Documents and ~/tmp


Sandboxing


Wildcard App ID


REST


App Store rejection?


Have you pushed to App Store before? If So, explain the steps.


Developer and Enterprise Accounts


Explain Notification Center


memory leak in IOS?


NSUserDefaults?


ViewDidLoad vs. ViewDidAppear


ViewDidLoad vs. ViewDidAppear- Remote Server Data


waiting for some thread to finish


layers


UIControls


overriding DrawRect?


singletons


Is UIKit Threadsafe?


more on memory leaks


Can we execute code with app in background? how?


lifecycle events


store user info


SwiftvObjC 2


Common UI Elements


XCTest


Unit Test


SQLLite



Categories


Categories 2


data types


synthesize


@dynamic


protocol ObjC


import/include


informal/formal ObjC


performblock


atomic


background modes


crash logs


persistent stores


NSPersistentStoreCoordinator


threadsaftey



weak ref block


ARC


ARCvsMRC


copy vs retain


strong retain


strong vs weak


weak v unowned


Memory management IOS


retain cycle





Data storage types in iOS

XIB vs NIB

Layers (Xcode Files)


CALayer


CAScrollLayer


CATextLayer


AVPlayerLayer


CAGradientLayer


CAReplicatorLayer


CATiledLayer


CAShapeLayer


CATransformLayer



CAEmitterLayer


5-07-2019 :
=========

LoginTree IT Interview question from Hyderabad :

1) DequeuereusableCellWithIdentifier: and cell with identifier difference

2) Coredata

3) SharedClass (Singleton how you will create)

4) Week and strong

5) Retain and copy

6) ivar and property

7) xml delegates and one important delegate is there in that

8) View inside 2 labels with dynamic size

9) What is size classes

10) Autolayout

11) ViewController life cycle

12) App life cycle not from delegate states 

13) Array and NSArray difference is nsmutablearray available in swift

14) How dequeueresuablecellwithidentifier will be create cells, how it knows about required cells and how it will create

15) NSNotifications and delegates difference

16) what is delegates

17) Design patterns (MVC and MVVC)

18)  ARC


6-07-2019
==================

Cognizant:

What is ui session
Write ui session code for url
Optional binding
Latest version updates
Any and anyobject
Let dic :[Strimg:Anyobject] =["3":dfghjjjj, "3":3] is this correct. 
Let a:Anyobject = 3
Let a:Any = 3 above two statements are correct or not.
Dependency injectors, 
Cocoa pods, cartheg like that
Pod update and install commends
What type of frame works you used
Alamofire
Json methods
Git, svn
Git commends for upload our project
Hoe you solve errors 
Debug 
How can you check Performance test  (Profile, instruments, etc…)
Testing 


10-July-2019: 3.06Pm call
======================

Push notifications

Login : How to login what you can do for login in backside.

How to handle login credentials each time user need to enter details.

What you find critical up to now

Sessions : do you have any sessions in your api’s

If session expired what you do

What back end technology you used for api’s and DB

App Store procedure to upload app

What is crashlytics

Have you any knowledge on third party gps device tracking



13-Nov-2019 HCL
==============

Optionals in swift 

What is optional Binding

Unit testing

MVVC

Access Specifiers (Open, public, private, file private, default)

Where we used these specifiers.

Push notifications explain process

Explain current project

Explain some application in your apps

If let vs guard let difference

Protocols in swift

How you can pass data from one vc to another vc

Explain MVC


What design patten u used up to now



13-Nov-2019 2.0PM (Zoom interview ) new company
========================================

Multithreading background thread

Push notifications procedure

Have you worked on Live GPS device tracking

What is your role in current application

What you do to get location of application in background continuously ,  how you manage the memory and issues 

Local storage options

How many ways you have to pass data from one vc to another vc 

Tuples 

Sqlite

In design and development what  you feel hard

What you preferred for development storyboard or coding

What are design patterns


Coredata versioning procedure


19-jul-2019(Friday - hyd)Hcl 2nd round Clint round
======================================


If app is in active what you do for notifications 
Gcd
Coredata
Persistentstorecontainee
Globalqueue
Optionalbinding
Current app discussions
Previous app discussions
URL Connection and urlsession 
Why not you use url connection 
URLSessionConfiguration 
Urlsession types
@escaping use
Map, flatmap, filter, reduce(higher order functions).
Guard let, if let, if else

19-Jul-2019 IBM
==============
What will happen when you click btn
Xib and storyboard difference
Notifications
When you get token what you do with that
If notification not registered what you do

What is fast enumeration in swift



NSURLConnection actually refers to a group of the interrelated components, like NSURLRequest, NSURLResponse, NSURLProtocol, NSURLCache, NSHTTPCookieStorage, NSURLCredentialStorage1.NSURLRequest objects are passed to an NSURLConnection object.2.The delegate responds asynchronously as an NSURLResponse, and any associated NSData are sent from the server.NSURLConnectionDelegate, NSURLConnectionDataDelegate (these are protocols)
Use of Weak :- 1. Delegates 2. Outlets 3. Subviews 4. Controls, etc.Use of Strong :- Remaining everywhere which is not included in WEAK.



What is GCD?

Dispatch Queues

Dispatch queues manages tasks in FIFO order.
There are two types of dispatch queues:
Serial Queues
Concurrent Queues
And Synchronous vs. Asynchronous

Thread Safety
Dispatch queues are thread safe. 

Types of Dispatch Queues
Main Queue
When your app launches, the system automatically creates a serial queue and binds it to the application’s main thread. All UI tasks have to be run on the main thread.
Global Queues
There are four global concurrent queues which are provided and shared by the system.
Quality of Service attribute indicates the priority of the tasks in the queue:
  • User-interactive: update the UI or other small tasks that should occur instantly. Tasks in this queue are the highest priority tasks and they will run on the main thread.
  • User-initiated: tasks in this queue are tasks that should run immediately -like opening documents or react to user actions. Tasks should complete in a few seconds or less. Will be mapped to High priority queue.
  • Utility: this queue is for longer tasks that should complete immediately (think tasks with a loading bar such as downloading or importing). Tasks should complete in seconds or minutes. Will be mapped to Low priority queue.
  • Background: tasks that takes minutes to hours to complete — indexing, syncing, etc… This queue is energy optimized and any disk I/O actions are throttled. Will be mapped to Background priority queue.
Custom Queues:developed and mainted by developers.



22-07-2019 second round interview
—----------------------------------------------------------


Do you submit app in appstore.
Latest project
What is the protocol, protocol in Swift.
Delegates
How can you implement delegates
What are closures
Closure examples and implementations
escaping, non escaping
Which type of database you used.
Are you worked on realm swift.
Explain about generics.
Tuples.
Explain about guard.
Lazy explanation.
Push notifications explanation.
Have you worked on background push notifications,we need to handle it before the push notifications.
Access modifiers.
Different between classes and structures.




https://medium.com/@abhineb/swift-questions-2b8d34c1afaf

Questions(Swift Only):-
4) How can we return multiple values from a method without using dictionary or array? OR What do you mean by “Tuple”?
https://www.hackingwithswift.com/example-code/language/what-is-a-tuple
8) What is difference between open and public in access level?
https://useyourloaf.com/blog/swift-3-access-controls/
9) What is difference between private and file private in access level?
https://cocoacasts.com/what-is-the-difference-between-private-and-fileprivate-in-swift-3/
10) What do you mean by internal and final in class?
https://medium.com/@MarcioK/swift-final-functions-under-the-hood-2deccd0b9437
11) What do you meany by lazy variables?
http://mikebuss.com/2014/06/22/lazy-initialization-swift/
13) What do you mean by defer keyword?
http://nshipster.com/guard-and-defer/
14) What is map, flatMap, filter & reduce. Please explain?
https://useyourloaf.com/blog/swift-guide-to-map-filter-reduce/
15) Can we inherit protocols?
YES
17) How to continue from one case of switch to another case? OR What do you mean by “fallthrough” ?
fallThrough
18) What is the difference between designated initializer and convenience initializer(convenience init)?
http://www.codingexplorer.com/designated-initializers-convenience-initializers-swift/
19) What is the difference between structure & class, when we can write the functions inside both?
https://stackoverflow.com/questions/24217586/structure-vs-class-in-swift-language
20) Can we inherit enum?
Yes
21) Can we pass multiple objects in enums? If yes how?
Yes
enum Trade {
case Buy(stock: String, amount: Int)
case Sell(stock: String, amount: Int) 
}
22) Can we add a new operator?
Yes
25) What’s the difference between between Any and AnyObject?
https://medium.com/@mimicatcodes/any-vs-anyobject-in-swift-3-b1a8d3a02e00
27) What do you mean by generics? Can you please write something that can explain generics?
https://www.raywenderlich.com/154371/swift-generics-tutorial-getting-started
31) Where you will write the code for swizzling in initialize or load? Why?
http://nshipster.com/swift-objc-runtime/
32) What do you mean by “??” ?
Nil-Coalescing Operator
The nil-coalescing operator (a ?? b) unwraps an optional a if it contains a value, or returns a default value b if a is nil. The expression a is always of an optional type. The expression b must match the type that is stored inside a.
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/BasicOperators.html
34) What do you mean by inout parameters and how to use them?
When to use inout parameters?

















No comments:

Post a Comment

Difference between == and ===

Difference between == and === https://stackoverflow.com/questions/24002819/difference-between-and == operator checks if their ...