0% found this document useful (0 votes)
1K views

iOS Interview Questions and Answers

The document discusses preparing for iOS interviews by focusing on two key aspects: answering technical questions correctly and convincing interviewers of your ability to deliver what they require. It provides a list of over 40 companies and touches on topics that may be covered in iOS interviews, including UI-related questions, storage, networking, and design patterns. The goal is to help developers prepare for their technical iOS interviews by understanding common question types and topics.

Uploaded by

abc ker
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

iOS Interview Questions and Answers

The document discusses preparing for iOS interviews by focusing on two key aspects: answering technical questions correctly and convincing interviewers of your ability to deliver what they require. It provides a list of over 40 companies and touches on topics that may be covered in iOS interviews, including UI-related questions, storage, networking, and design patterns. The goal is to help developers prepare for their technical iOS interviews by understanding common question types and topics.

Uploaded by

abc ker
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 164

iOS Interview Questions and Answers

BY: SANDEEP REDDY CHALLA(iOS Tech Lead)

A question we are frequently asked, usually by less experienced iOS developers, is how to
prepare for an iOS interview. Most candidates look for our advice for preparing on technical
details such as what frameworks or libraries to invest their time in, what architectural
patterns should they be using, and other technical details. We believe that it is essential to
acquire the knowledge and develop a proper understanding of such tools and notions and
the ability to use them efficiently. Moreover, we like to introduce developers in thinking
somewhat differently when considering changing jobs or even starting a career in software
development, emphasising on the relationship and mutual benefits for both you, the
employee, and your future employer.If your goal as a candidate, is solely to receive an offer,
regardless the characteristics of the employer and team, then you should probably focus on
two aspects; answering all the questions correctly during the interview and convincing the
interviewers that you can deliver what they require. You can approach interviews as a
“number’s game” where the more of them you attend, the more offers will get if you’re
meeting the criteria, especially when the demand for iOS developers in the job market is
high. There are multi-billion active Apple devices in the world. With the number of iOS
users growing steadily across the world, the future looks bright for iOS app developers.
Apple and iOS devices continue to have a loyal customer base, helped in part by innovative
new devices such as Apple TV and Apple Watch.There has never been a better time to
become an iOS developer. However, if you have already given an iOS interview, or have
more questions, we encourage you to submit it with subject as iOS Interview Questions and
Answers to sandeep.challa73@gmail.com.I will answer them for you.This document
continues the work and I will update it every week. In this week edition, I added several
new things from my experience and companies where I worked to help you be ready for
iOS interview questions now. I updated the article to fully focus on Swift, since Objective-
C has become rarer, and added questions on Fundamentals of iOS, Unit Testing and
Architecture for Scale.When you’re preparing for your technical iOS interview, it’s
important to understand what you could be asked about topics and what is expected from a
seasoned iOS developer. These questions and topics (in one form or another) are used by
many companies to gauge the level of experience in an iOS candidate. They cover various
aspects of iOS development and aim to touch upon a broad understanding of the platform.
Senior developers are expected to be able to ship full iOS products from start to finish, after
all. But in large companies with big iOS development teams (think 25+ people)
specialisation and focus on a deep knowledge of a specific problem such as networking also
occurs though. This is by no means an exhaustive list, but it can help you prepare for your
upcoming technical iOS interview.
The questions covered in this post touch upon a broad spectrum of topics iOS developers
should know. This is by no means a comprehensive list. These questions are based on
research I’ve done. This approaches interview prep as a holistic overview of iOS topics and
concerns every iOS application has. It breaks down questions into the following groups: UI-
related questions (UIView, AutoLayout, etc.), storage questions (persistence, user defaults,
core data, etc.), networking (http, NSURLSession, Alamofire, etc.), and design patterns and
architecture questions (MVC, MVVM, SOLID, etc.). It has been a great help for more than
a thousand of developers who used it help them with interview prep.

I am sure that if you read all questions answer, then you will be crack your next interview.
All the best.

1. Intelegain Technologies
2. Infosys
3. Reliance General
4. India Infoline
5. Meru Cab
6. Thyrocare
7. Interview-1
8. Advanced Interview Questions
9. Interview - 2
10. Interview - 3
11. Call Ambulance
12. Shoppers Stop
13. Saint Gobain
14. Airtit
15. Synergy Technology Service
16. Cousins Infotech
17. Vasudhara Vision
18. Nanostuffs Technologies
19. HN Web Marketing
20. Exceptionaries Technologies
21. Surebot Technology Solution
22. Zomato
23. XIPHIAS Software TechnologiesXIPHIAS Software Technologies
24. Capillary Technologies
25. Volansys Technologies
26. NeoSOFT Technologies
27. Adaps
28. Space-O Technologies.
29. TimesOfMoney
30. Capegemini
31. 24/7 Software
32. GyanMatrix
33. Asterika Infotech
34. NeoQuant Solutions
35. Infrasoft Technologies
36. GOQII
37. OneKosmos
38. Reliance Mutual Fund
39. Network18
40. Emproto Technologies
41. Bruviti
42. Leap & Scale
43. Wipro
44. XEBIA IT

45. Drona HQ
46. Globant
47. Angel Broking
48. Welldoc
49. Synchronous Technology
50. Jet Synthesys
51. L&T Infotech
52. Moofwd
53. Futurism Technology
54. TCS

Intelegain Technology iOS Interview Questions


Location : Turbhe
Date : September, 2018

1. What is difference between datasource and delegates?


2. What are methods of Uitableviewdelegate and Uitableviewdatasource?
3. Which design pattern you are using?
4. What are MVC?
5. What are persistent storage in iOS?
6. What is difference between coredata and sqlite?
7. Have you use sqlite?
8. For what purpose we are using sqlite in our app?
9. What is category in objective c?
10. What you have used for webservice parsing?
11. How do we implement multithreading?
12. What is GCD?
13. Have you used core location framework?
14. For display Google map, what you have used?
15. Can you tell me collectionview delegates and datasource methods?
16. Have you experience of iPad app?
17. Do you need another storyboard for iPad UI?
18. Can we have multiple storyboard?
19. Why you need another storyboard required?
20. Can you explain viewcontroller lifecycle?
21. Have you used stack view? What is need to use stack view?
22. In which format you are uploading image?
23. How many way we can store image on server?
24. Which is first method when app start?
25. When push notification comes, which method get called?

CTS Technology iOS Interview Questions :


Date : 27, September, 2018

1. What is delegate?
2. What is need of protocol?
3. What is diff between delegate and notification?
4. Want is collection type in Objective-C and Swift?
5. What is extension in Swift?
6. What is different between Swift and Objective-c?
7. What is sub classing?
8. Oops concept
9. What is difference between class, enum and structure?
10. What is difference between strong and weak?
11. What is optional chaining and optional binding?
12. What is meaning of following in Swift
13.What is access specifier in iOS?
14.What are higher order methods?

























15.What is background state? Do you know about Gcd, operationqueue?


16.What do you know about MVC and MVVM ?
17.What is sychronus and ascynchronus?

Infosys iOS Interview Questions


August, 2018

1. What was the latest version of iOS you worked with? What do you like about it and
why?
2. What is an iOS application and where does your code fit into it?
3. What features of Swift do you like or dislike? Why?
4. How is memory management handled on iOS?
5. What do you know about singletons? Where would you use one and where would
you not?
6. Could you explain what the difference is between Delegate and KVO?
7. What design patterns are commonly used in iOS apps?
8. What design patterns besides common Cocoa patterns do you know of? -> MVC
9. Could you explain and show examples of SOLID principles?
10. What options do you have for implementing storage and persistence on iOS?
11. What options do you have for implementing networking and HTTP on iOS?
12. How and when would you need to serialize and map data on iOS?
13. What are the options for laying out UI on iOS?
14. How would you optimize the scrolling performance of dynamically sized table or
collection views?
15. How would you execute asynchronous tasks on iOS?
16. How do you manage dependencies?
17. How do you debug and profile things on iOS?
18. Do you have TDD experience? How do you unit and UI test on iOS?
19. Do you code review and/or pair program?

Reliance General iOS Interview Questions


Telephonic
6, July, 2018

1. What is protocol?
2. What is need of protocol in ObjectiveC?
3. Diff between notification and delegate
4. What type of constraints for auto layout for any view?
5. How you will implement scrollview for any long form?
6. What are steps to implement for push notifications?
7. If there are two views up and bottom, up-view is 60% of superview and 40% of
superview respectively, then what to do with constraint?
8. How to implement expand type uitableviewcell?
9. If I have dynamic content in tableviewcell, then how it will be calculated?


























India Infoline iOS Interview Questions


Andheri, Mumbai
July,2018

1. What is difference between == and isequals in string?


2. Which frame work used for current location?
3. How to find current location?
4. Lifecycle of view controller
5. When view will disappear?
6. Diff between viewdidload and viewwillappear?
7. What is ARC?
8. What is difference between strong and weak?
9. What arc do for strong and weak relationship?
10. Is memory freed by arc automatically?
11. Default type of property, i.Strong or weak ii. Atomic or non atomic
12. What is atomic and non atomic property?
13. Which property type keyword with iboutlet?
14. Which one fast from atomic or nonatomic?

Meru Mobility Tech iOS Interview Questions


Andheri, Mumbai
Date : 4,Aug,2018

1. What are types of local storage database


2. Can we save data in keychain?
3. What is secure type to store datal
4. Which type of encryption you have used?
5. Rest API and Soap API
6. Which API I have used in our project?
7. Which are the steps to call API?
8. What is end to end requirements for Apple push notifications?
9. Which call back method called when notification received?
10. What type of features of google maps?
11. Which API you have worked in Google map in your project?
12. What is difference between mutable array and immutable array?
13. Which one is thread safe from mutable array and immutable array?
14. Which architect you have used in your project?
15. What is MVC? How you have implement this?
16. Int Array sorting in ascending
17. What is difference between xib and storyboard? Which one is better?
18. What is most challenging task you have done in your project?

Thyrocare iOS Interview Questions


Turbhe, Navi Mumbai
July,2018

1. Diff between static constructor and private constructor



































2. What is category?
3. What is extension?

IBM Technology iOS Interview Questions


Date : 23, September,2018

1. About Projects
2. Difference between tableview and collection view
2. Which is better scroll view or page view or collection view and why
3. Difference between bounds and frame
If I want have a label in a uiview, what will be the bounds and frame
4. What are generics in swift?
5. What are MVC pattern..in depth?
6. What is in out parameters
7. Access specifier in swift
8. Stackviews advantages. why and when to use stackviews?
9. What are size classes? Explain with example
10. How to handle optional in swift?
11. Have you worked with Auto layout?
12. How to submit an app to app store?
13. What is app thinning?
14. What is a singleton class?
15. What are closures?
16. What is extension and when and why to use them?
17. When to use a collection view and when to use a tableview?
18. What are observables in swift?

Tech iOS Interview Questions 2018

1. What design patterns are commonly used in iOS apps?


2. What is MVC?
3. What is MVVM?
4. What are the common layers of responsibility that an iOS application has?
5. What are SOLID principles? Can you give an example of each in iOS/Swift?
6. How do you manage dependencies in iOS applications?
7. What is Functional Programming and Functional Reactive Programming?
8. What are the design patterns besides common Cocoa patterns that you know of?
9. What are the challenges in working with UI on iOS?
10. What do you use to lay out your views correctly on iOS?
11. What are CGRect Frames? When and where would you use them?
12. What is AutoLayout? When and where would you use it?
13. What are compression resistance and content hugging priorities for?
14. How does AutoLayout work with multi-threading?
15. What are the advantages and disadvantages of creating AutoLayouts in code versus
using storyboards?




































16. How do you work with storyboards in a large team?


17. How do you mix AutoLayout with Frames?
18. What options do you have with animation on iOS?
19. How do you do animation with Frames and AutoLayout?
20. How do you work with UITableView?
21. How do you optimize table views performance for smooth, fast scrolling?
22. How do you work with UICollectionView?
23. How do you work with UIScrollView?
24. What is UIStackView? When would you use it and why?
25. What alternative ways of working with UI do you know?
26. How do you make a pixel-perfect UI according to a designer’s specs?
27. How do you unit and integration test UI?
28. What is the storage layer for in iOS applications?
29. What can you use to store data on iOS?
30. What is NSCoding?
31. What is NSUserDefaults?
32. What is Keychain and when do you need it?
33. How do you save data to a disk on iOS?
34. What database options are there for iOS applications?
35. How is data mapping important when you store data?
36. How would you approach major database/storage migration in your application?
37. What is HTTP?
38. What is REST?
39. How do you typically implement networking on iOS?
40. What are the concerns and limitations of networking on iOS?
41. What should go into the networking/service layer?
42. What is NSURLSession? How is it used?
43. What is AFNetworking/Alamofire? How do you use it?
44. How do you handle multi-threading with networking on iOS?
45. How do you serialize and map JSON data coming from the backend?
46. How do you download images on iOS?
47. How would you cache images?
48. How do you download files on iOS?
49. Have you used sockets and/or pubsub systems?
50. What is RestKit? What is it used for? What are the advantages and disadvantages?
51. What could you use instead of RestKit?
52. How do you test network requests?
53. What is let and var in Swift?
54. What is Optional in Swift and nil in Swift and Objective-C?
55. What is the difference between struct and class in Swift? When would you use one
or the other?
56. How is memory management handled in iOS?
57. What are properties and instance variables in Objective-C and Swift?
58. What is a protocol (both Obj-C and Swift)? When and how is it used?
59. What is a category/extension? When is it used?
60. What are closures/blocks and how are they used?
61. What are Singletons? What are they used for?














































62. What is Delegate pattern in iOS?


63. What is KVO (Key-Value Observation)?
64. What does iOS application lifecycle consist of?
65. What is View Controller? What is its lifecycle? and much more.
66. What is difference between computer science and engineering
67. What you have done without webservice?

Hexagon Technology iOS Interview Questions


Date : 25, September, 2018

1. How to use obj c file in swift and vice versa?


2. how objective c is better than swift?
3. Features of swift. Optional.
4. Tuples. Diference between tuples and struct and class.
5. Generics.
6. What is a functional programming language?
7. Higher order functions. Maps, filters, reduce
8. Various design pattern in iOS
9. What are the disadvantages of MVC design pattern
10. What is MVVM?
11. What is Singleton Design pattern?
12. What are delegates?
13. What is the difference between delegate and kvo.
14. Concurrency in iOS
15. What are Synchronous and asynchronous tasks
16. What is NSOperationQueue?
17. Difference between GCD and NSOperationQueue
18. How to save data in SQLite security?
19. On view two label A & B,On iphone 5 & iphone 6, I want Label B below of label A
And other devices it wants in the Same Line. How can I achieve it?
20. Inbuilt encryption Technic in iOS.
20. Difference between SHA and AES encryption.
21. How to use swift class in objective c class?
22. Which precaution we have to take care of, of implementing Autolayout
programmatically for both iPhone and iPad?
23. How to maintain concurrency between SQLite update query and database delete
query?
24. Mapping on SQLite database.
25. How to restrict users to fetch SQLite files?
26. What are Vary Traits and where to use them?
27. Category and extension difference
28. Struct and Class difference
29. what is protocol?
30. Closure
31. Convenience initializer
32. what is overloading?




33. what is override?

Date : 25, September, 2018


Hotstar, Jim

1. Which executes faster let/var and how it impacts memory?


2. Thread and process diff
3. Extension and inheritance diff. and effect on memory.
4. A class contains three variables and one static variable and one static func then what
will be the size of class?
5. Which data structure is used in tableview.dequereuseidentifer method?
6. How will you detect if your app is uninstalled in case of push notification as your
server will continuously push messages even though user has uninstalled the app.

Call Ambulance iOS Interview Questions


Company: Call Ambulance
Location: Hyderabad
Date: September 2018

1. How to configure push notifications?


2. What is gcd? Explain it.
3. Did u worked on geofencing? Explain methods in brief.
4. To upload 10 images what u will use?
5. Explanation of threads concept.
6. Did u used instruments?? If yes. For what purpose you used it?
7. What is the difference between swift 3 and 4.2?
8. Explain about the View life cycle.
9. Which payment gateway u implemented in ur projects?
10. What are the categories how u used those explain?
11. What is size class?
12. Difference between assign and retain.
13. Difference between Swift array and objective c array.

Practical Task :
Save locations and create geo-fencing there with a radius of 100 meters. While entering or
exiting from that radius we should get one local notification.

Shoppers Stop iOS Interview Questions


Location : Malad, Mumbai
October, 2018

1. What is optional?
2. Why optional feature is introduced in Swift?
3. How do you check whether optional has value or not?
4. How many way we check optional has value?
5. Is exclamation mark for unwrapping is good practice?

6. What is optional chaining?


7. Why did we used structure?
8. Which Swift version you are working?
9. What is @escape keyword?
10. If I have array of 1 to 9. I have switch in which I am passing number as 5. Case is like
that number > 9, number > 8,. ...number >1. If case number > 4 is execute , then control
goes out of switch. But I want to execute next cases. How can I do?
11. IBOutlet in uiviewcontroller what property attribute is good? Strong or weak.
12. I have 100 cells. In each cell I have 5 button. How can I check which cell button is
clicked?
13. On click on button, customcell.swift or viewcontroller.swift, in which control of
program goes?
14. What is ideal practise for cell button click event declaration in which, customcell.swift
or viewcontroller.swift?
15. UITableViewCell height auto
16. How to implement protocol method in our view controller's?
17. What is extension?
18. Why we need extension? Have you used? Where?
19. Which type of web service you have used?
20. How you have passed parameters to web service?
21. How to call 3 web services asynchronously? What will happen after calling web
service? Is it stopped or any other flow is working?
22. Have you used GitHub?
23. Have you used cocoa pods?
24. Sqlite FMDB or normal?
24. I have 3 services which fetches, insert, delete records for SQLite. But the response came
at the same time. How you will manage?
25. How you manage for sqlite, if fetch, update,delete action from from 3 different threads
at a time on row?
26. Flow of push notifications
27. I install app the first time, what will happen with push notifications?
28. Where push notifications tokens generated?
29. What is @escaping and @nonescaping?

Saint Gobain iOS Interview Questions


Location : Andheri, Mumbai
Date : Oct, 2018

1. Process of Apple Push Notification


2. Can you convert p12 file into pem files?
3.If I denied push notification permission on start of app, is there any way to send
notification to user back? How you know user has denied permission?
4. What is method of register notification and what is method for ask permission for
notification? How you again send notification if he has denied permission first time?
5. I have one label in all forms, Where I have to set same text message. Where I have to set
this string?
6. What is benefit of Singleton class?

7. What is different between Swift extension and Objective-c category? Where you have
used extension in your project?
8. What are size class? How many size class?
9. I want to transfer value from ViewControllerA to ViewControllerB and also pass value
from ViewControllerB to ViewControllerA. How can I achieve this? If using delegate
protocol, then write code.
10. Difference between local notification and delegates?
11. Can model and view directly communicate? Can view and controller communicate?
How view and controller can communicate? Give example of uitableview for same.
12. UITableViewDelegate and UITableViewsource methods.
13. Application States
14. Difference between Suspended and Termination state

15. How you will decrease app size if your app's size is increasing?
16. In navigation controller, A-B-C-D, I want to come from D TO A, How is it possible?
17. Difference between is ? and ??
18. Difference between struct and class
20. What is optional Chaining?
21. Difference between closure and method
22. Why you use closure in your project? Example of closure. Write code.
23. Difference between Swift and Objective-c protocol
24.
Struct view() {
var str = "Hi"
}

Var view1 = view()


Print(view1.str)

Var view2 = view1


View2.str = "hello"
Print(view1.str)

Output:?

Class view() {
var str = "Hi"
}

Var view1 = view()


Print(view1.str)

Var view2 = view1


View2.str = "hello"
Print(view1.str)

Output?
25. Have you used an access specifier? Why you have used public Access specifier?
26. What is KVO?
27. What you have used for web services requests?
28. Difference between NSUrl and NSUrlSession
29. What you have used for not blocking your app while the web-service response is
coming?
30. What are blocks?
31. Difference between Blocks and Methods

Airit iOS Intervew Questions


Location : Charni Road, Mumbai
Date : Oct, 2018
Mode : Telephonic

1. What is multiplier?
2. Difference between multiplier and ratio.
3. I have one button and I want my button size will be changed according to device size,
what you will prefer? Multiplier or Ratio? Why?
4. Difference between struct and class.
5. What is stack and heap?
6. Can you explain MVC through UITableView?
7. HeightForRowAtIndexPath is view or controller part in MVC?
8. Difference between notification center and delegates?
9. What is category?
10. Query for last inserted row in SQL database.
11. I have array of 10000 dictionary. And In dictionary, I have name and age key. I want
find indexes of name as 'Manan Shah' in dictionary. How we can find?
12. How to take common elements from two array?
13. Why containsObject : Id why Id type in containsObject?
14. What is p12 file?
15. What is pem file?
16. What is benefit of Singleton object over static object?
17. Is it possible to update Singleton object?
18. Is it possible to update Singleton value?
19. Which delegate method called when app icon is clicked?
20. If I click on app icon while app is background which delegate method is called?
21. Which delegate method called when I click on push notifications?
22. Add column query in sqlite
23. What is method swizzling?
24. Difference between innerjoin and outerjoin?
25. Difference between strong and weak property.
26.Difference between nill and null.
27. What is completion handler?
28. Why we need completion handler?
29. Difference between completion handler and notification center.
30. Difference between frames and bounds.

31. What is the highest priority?


32. What is NSCoder?
33. Can we send our latitude and longitude to the server, but in the background or not
running mode?

Synergy Technology Service iOS Interview Questions


Location : Andheri, Mumbai
Oct-2018

1. Have you used iprinter or any way to print from your app?
2. What are different types trigger point of local notification? I.e location based
3. Why soap request? Why everyone use rest API?
4. Do you know SMTP? Is it soap type or rest type?
5. What is category in Objective-C?
6. What are blocks in Objective-C?
7. For API call, which you are working on, normal, aftp or any third-party library?
8. Difference between block and completion handler
9. What blocks basically do? Why we use blocks?
10. In navigation view controller, form is open from right to left. I want to open from
bottom to top. How? What type of presentation is there for bottom to top?
11. How many ways we can present view controller?
12. After getting data from web response, how to store or parse data?
13. What is Object mapping that helping Jon parsing?
14. In iphone,I want label at top side and in iPad I want label in center, how will I manage
this?
15. What kind of encryption you have managed in your application?
16. Have you used a third party for encryption, internet reachability?
17. Is apple have reachability methods?
18. You have called web service. Meanwhile, how can you check for network availability?
19. How can you manage 2 storyboard navigation?
20. Why table view cell separator leave some space before?
21. How to customize UIButton such as label comes under image?
22. How to make round button of square button using static property?
23. How to take multiple type of cell in uitableview? If you manage cell using if else if
condition, what other options?
24. Why we use struct?
25. Difference between struct and class?
26. In Struct and class init must be written or not? Like initwitjTitleandAge.
Strct {
Var title : String
Var age : Int
}
Class {
Var title : String
Var age : Int
}
27. Difference between

let assumedInt: Int! = 123


let assumedInt: Int? = 123
28. Can I store null value in info.plist?
29. Can I store class data in NSUserDefault?
30. What is a bundle identifier?
31. What is Team Id?
32. Is my app id = team id + bundle id?
33. What is app id?
34. Where you can set background functionality like background music?

Cousins Infotech iOS Interview Questions


Location : Surat, Gujarat
Date : June, 2016
Level : Fresher

1. OOPS Features
2. Explain Object Overloading, Overriding
3. What are app delegate methods?
4. Application state
5. Which app delegate method is used for applicationstarting?
6. iOS Application starting point.
7. What is .h and .m file in objective c?
8. Explain viewdidload and viewwillappear.
9. What is IBOutlet and IBAction?
10. What is atomic and Nonatomic?
11. What is multithreading?
12. What is synthesize?
13. What is an interface in objective c?
14. How to show webservice json data in UI? How to mark get/post method for web-service
for json parsing?
15. Difference between NSArray & NSDictionary.
16. Which framework is used for our UI or Views?
17. How to pass data from one view controller toanother view controller?
18. What is cocoa pods?
19. What are constraints?
20. What is Plist?
22. What is NSUserDefault?
23. What is a combined string and divide string?
24. What is MVC?
25. What is autolayout?
26. What is stack view?
27. What is size class?
28. What is a gesture recognizer?
29. How to popup alert view controller?
30. How to put yes, no button in the alert view controller?

31. What is diff between obj c and swift?


32. What is let in swift?
33. What is diff between let and var?
34. Any social integration knowledge?
37. Which functionality we need in cab application?
38. Which frameworks can require in map?
39. Do you know about ionic, PhoneGap?

Vasudhara Vision iOS Interview Questions


Location : Surat
Date : June,2016
Level : Fresher

1. Difference between C++ and Objective C


2. Inheritance
3.Concepts of Oops
4. What is auto-layout?
5. Which view is best for dynamic or unknown length of array?
6. What is logic behind your tic-tac-toe game project?
7. What is used to store task in to-do list app?
8. How to store data in core data?
9. What if did not tick mark for core data at starting?
10. Which api used in weather app?
11. How can I put image on pin on map?
12. How many gestures are there?
13. Hove you used in it?
14. Which 3rd party library you have used in web-service?
15. What is used for json parsing?
16. Have you used map?
17. What is special steps for getting current location?
18. Have you used push notification?
19. Do you know background fetch?
20. What you prefer? Xib or storyboard?
21. Have you used portrait and landscape UI?
22. Machine test : 1. Json Parsing and Show data in tableview
2. Get current location and see it on label of latitude, longitude.

Nanostuffs Technologies iOS Interview Questions


Location : Pune
Date : June, 2016

1. Sum of Int array.


2. Remove html tags from string.
3. What is APNS?
4. What is GPS?
5. What is delegate?

6. Calculate distance between two points through gps.


7. Difference between Json and XML.
8. What is Storyboard?
9. Device Size of all iphone, ipad size

HN Web Marketing iOS Interview Questions


Location : Kothrud, Pune
Date : June, 2016
Level : Fresher

1. What is ARC? Explain it in brief.


2. Property and Its attributes.
3. Synthesise and Dynamic
4. Protocol
5. Category
6. Diff between Protocol and Category
7. Is there any required method inUITableViewDelegate?
8. List of local database.
9. Latest version of XCode, iOS.
10. JSon Parsing
11. XML Parsing
12. Give some detail about CLLocationManager Delegate
13. Difference between TableViewDelegate andTableViewDatasource

Exceptionaire technologies iOS Interview Questions


Location : Baner, Pune
Date : June, 2016
Level : Fresher

1. How to null singleton class object?


2. Reverse string program in objective C
3. Diff between NSMutableString and NSString.
4. Diff between NSArray and NSSet.
5. What is use of NSNumber?
6. How to goto another view controller using segue?
7. Diff between frame and bound.
8. Which datatype image will be stored in sqlite?
9. Finalize method in sqlite
10. Which framework needed in map?
11. What is id type and what is use of it?
12. What is web service?
13. What is get and post method?

Surebot Technology Solution iOS Interview Questions


Bangaluru, Karnataka
Date : 20-Feb-2019

1. How Uber taxi type apps manages the signal strength and shows if the user have low
network?
2. Write a program to extract only upper case letter from given string.
3. Difference between tableview and collectionview
4. How to implement delegate in swift?
5. What is optional chaining in swift?
6. Write a program to reverse a string in swift?

Zomato iOS Interview Questions


Location : Bengaluru, Karnataka
Date : Feb, 2019

1. Explain about Lazy properties.


2. What is Operator overloading?
3. What is Unmanaged objects?
4. Different types of Control statements.
5. Access Controls in Swift.
6. Different type of sort algorithm.
7. Persistent storage in iOS.
8. Difference between Stackview and Normal View.
9. Difference between class and structure.
10. Explain Delegate & protocol for Data passing in swift.
11. Which platform is better, iOS or Android ? In terms of development. Give examples
to support your answer.
12. Difference between Frame and bounds ?
13. What is ARC ?
14. Are delegates strong or weak? -> Weak
15. What are strong and weak properties ?
16. How to implement real time in an app?
17. How you handle & manage data offline and online?

XIPHIAS Software Technologies iOS Interview Questions


Location : Bengaluru
Date : Feb, 2019

1. Explain Dispatch queue vs Operation queue.


2. Explain Singleton pattern and it's drawback.
3. What is protocol?
4. Delegates and Data source.
5. Why we use Alamofire library?
6. App states.
7. Atomic vs Non-atomic.

8. Explain Retain cycle.


9. Weak or retain attribute.
10. Could you explain clearly about retain attribute? When we will use?
11. Atomic is always guarantees to return a value.Why?

Capillary Technologies iOS Interview Questions


Location : Bengaluru, India
Date : Feb, 2019

1. What is defer in iOS?


2. What is swift futures?
3. What is lazy?
4. Write a program to find missing number of array of 1 to n.
5. Write a program to revere string without using reverse method.

Volansys Technologies
Location : Ahmedabad, Gujarat
Date : Mar, 2019

1. Different between map and flat map (Higher order function)


2. Advantage of Swif over Objective C.
3. Difference between MVC and Viper.
4. What is protocol explain with a little example?
5. Explain the map with a little example(higher-order function).
6. Difference between NSOperation queue and GCD.
7. When to use GCD and NSOperation queue in your application?
8. Test cases in Xcode (like how to find a bug, how to find unusual array, string.)
9. How many types of storage in iOS?
10. Advantage of Core Data over Sqlite.
11. Is it possible to use primary key, foreign key in core data?
12. How to delete data from coredata? Explain query.
13. How to generate developer certificate?
14. If we revoke developer certificate then live app (app store application ) is working or
not working?
15. Explain your app's tough part and you fill proud to do it.

NeoSoft Technologies iOS Interview Questions


Location : Hinjewadi, Pune, Maharashtra
Date : March, 2019

1. What are different methods to create NSOperationQueue?


2. What is GIT stash?
3. What is presenter class and how to show data in it?
4. NSOperationQueue Vs. GCD.
5. Different collection types in swift and their differences.

6. How is 'Set' different from 'Array'? List out different methods of 'Set'.
7. Functional programming?
8. Mutability in struct.
9. Codable advantages and disadvantages.
10. Extension limitations.
11. Any Vs. AnyObject.
12. Create a protocol which can only conform to classes.
13. Disadvantages of Core Data.
14. If let Vs. Guard let.
15. Unit test cases.
16. Code coverage.
17. Swift Vs. Objective-C.

Soft Technologies iOS Interview Questions


Location : Dadar, Mumbai, Maharastra
Date : April, 2019

1. What Is NSPredicate?
2. Which Class Will Be Used For Sorting?
3. Difference Between SOAP n REST?
4. Process To Integrate Google Map?
5. How To Add Custom Marker On Map?
6. What Is GCD?
7. How To Add Priority In Multithreading?
8. What Is Map() Function?
9. What Is Optional Binding And Optional Chaining?
10. Application States
11. Steps To Integrate FCM?
12. Delegate methods Of Firebase Notification ?
13. What Is Silent Notifications?
14. Difference Between NSArray And NSSet?
15. What Is Atomic and Non Atomic?
16. ViewController Life Cycle.
17. Difference Between Protocols And Notificationcenter.
18. How To Play Audio Video In App?
19. What is data task for URLSession?
20. Delegate and Data Source Methods Of Tableview.
21. What is safe area?
22. How To Share Something On Social Media (Like Fb, Twitter, Insta) From Ur App ?
23. Difference Between App Bundle And File Directory?
24. Types Of Provisioning Profile.
25. How To Record Audio And Video?
26. How To Solve Conflict In Git Repositories?
27. How To Handle Crashes In Swift ?
28. How To Do Unit Test In Xcode ?
29. How To Declare Custom Cell?
30. What Is The Use Of dequeuereusablecellwithidentifier ?

31. How To Declare Protocols? Write Code?


32. How To Compress Image Or Video?
33. How To Check Whether It Is Dictionary Or Array When We Get Response From
Server?
34. What Is Escaping And Non Escaping Closures?
35. How To Pass Closure As A Parameter To A Function?

Adaps iOS Interview Questions


Location : Hyderabad, Telangana
Date : March, 2019

1. What is Singleton class?


2. Write a "iOS Developer" in a reverse string by program.
3. Get first 10 prime numbers from 1 to 10.
4. [2,7,5,2,0,8,5,9] remove duplicate elements from above array.
5. Write one example for fast enumeration.
6. Write one example of custom delegates.
7. How many ways to pass data from one view controller to another view controller?
8. ["a","l","l","T","h","e","b","e","s",t"] write a program to convert above array to
string.

Space-O Techonologies iOS Interview Questions


Location : Ahmedabad, Gujarat
Date : Mar, 2019

1. Life Cycle of View Controller.


2. What is init method?
3. Explain about APNS.
4. How to customize the size of tabbar?
5. Which payment gateway you used in your past projects? How it works?
6. How to save cards in payment?
7. How to draw path from source to destination?
8. How to fetch user current location?
9. Can we set priority in asynchronous call?
10. Explain App Cycle.
11. Enlist notification delegate methods.
12. Explain Multiplier and Content hugging.
13. Difference between if let & guard let.
14. How to send image to server?
15. How can save image in NSUserDefault?
16. Explain singleton class.
17. What is Provisioning Profile? How to create it?
18. Difference between google map & apple map?
19. What is marker clustering in map?

TimesOfMoney iOS Interview Questions


Location : Airoli, Navi Mumbai
Date : April, 2019

1. What Is IBInspectable And IBDesignable?


2. What Is Defer?
3. Difference Between UIWindow And UIView?
4. How Push Notifications Work?
5. Difference Between Datasource And Delegate?
6. What Is Protocol And Delegate?
7. Can Protocols Have Optional Methods?
8. Difference Between If Let And Guard Let?
9. What Is Localization ?
10. Tell Me About Encoding And Decoding
11. What Is MVC?
12. How To Access AppDelegate Methods In Other Class?
13. Difference Between Inheritance And Extensions?
14. Which Design Pattern You Follow? Why?

Capegemini iOS Interview Questions


Location : Pune
Date : March, 2019

1. Explain About application authentication.


2. Tableview reuse in different controllers in different class ( can we have same identifier)
3. Design patterns with architecture.
4. MVC vs MVVM calls.
5. Deletion rules in Core Data.
6. How to mutate structure variable without using mutating function variables.
7. Data passing from completion handler from one view controller to another while API
calling.
8. Weak vs unowned variable. Is weak/unowned variable used in @non-escaping variable?
9. What is agile? Spikes in Agile.
10. Enlist & explain various GitHub Commands.
11. GCD vs NSoperation Queue. Explain NSOPERATION Priority.
12. Class vs Structure in Deep.
13. Explain Ssl pinning.
14. Explain all access specifiers.
15. What is database concurrency?
16. Explain VIPER.
17. Create a class that can not be subclassed. -> Ans : Use final
18. Explain error handling.

Location : Airoli, Mumbai


Date : 18-Jan-2020

1. Difference between REST and SOAP api. Which one is most secure? Which one you will
choose for your application and Why?
2. What is new in Swift 5.1?
3. What is string interpolation in Swift 5.1?
4. Which tools is used for Crashlytics?
5. what is .dysm file? Where you can get that file?
6. ViewController Lifecycle
7. Difference between Class and Struct.
8. What is flag in memory for local variables?
9. In Swift, which inheritance support, multiple inheritance or multilevel inheritance?
10. Make one protocol and how to implement, write code.
11. Can protocol be file private?
12. Can we make init method in protocol?
13. What is QOS?
14. What is access specifier?
15. Difference between Open and Public.
16. How to pass data from one view controller to another view controller?
17. Types of apple account. What is for enterprise account?
18. What types of certificates are needed in iOS development and deployment?
19. Is distribution certificate support wild mark (*) ?
20. What is vary trait in auto layout?
21. What is content hugging priority?

Location : Mumbai
Date : March, 2021

1. What is singleton?
2. What is major changes in Swift 5, that is not in Swift 4.2 ?
3. Difference between FCM and APNS.
4. What is silent notification?
5. Is it possible to get silent notification via APNS ?
6. How to implement APNS?
7. How to get notification with image?
8. What is higer order function?
9. Difference between Class and Structure.
10. What is protocol?
11. Can we use multiple inheritance in Swift?
12. Tell me about Core Data Stack.
13. How to implement multi threading in Core Data?
14. How to implement multi threading in Swift?
15. What is content hugging priority?
16. What is content compression priority?

17. In iphone, I want to show tableview and In iPad, I want to show collection view.
How to do this?
18. What is CI/CD ?
19. How to know where memory leak happening?
20. Tell me procedure to upload app to appstore.

247 Software iOS Interview Questions


Location : Pune
Date : March, 2019
Mode : Skype

1. Can structure confirm protocol?


2. Can enumeration confirm protocol?
3. Can we declare variable in protocol?
4. Can we add function in enumeration?
5. What is closure? Why we use closure instead of function sometime?
6. Closure is value type or reference type?
7. Do you know escaping and non-escaping closure?
8. How to handle exception in swift?
9. How can define function throw error?
10. Difference between normal function and function ending throw?
11. What are condition for making Singleton class?
12. Why we use static variable in Singleton class?
13. When static variable deinitialize?
14. In which memory static variable stored? Stack, heap,..? -> Heap
15. Disadvantage of Singleton Class.
16. List of access specifier.
17. Difference between public and internal access specifier.
18. Difference between open and public.
19. What is file private? What if multiple class in single file without file private?
20. Tell me something about delegate.
21. Base class for uitableview, Unbutton, nsobject.
22. Is it compulsory to mention nsobject in swift inheritance ?
23. Swift is protocol oriented or object oriented?
24. Importance of protocol.
25. Difference between swift protocol and objective C protocol.
26. Content hugging resistance and content hugging priority.
27. What are size classes?
28. Size class for iPad.
29. Where closure will be stored?
30. Difference between Swift and objective-c.

GyanMatrix iOS Interview Questions


Location : Bengaluru, Karnataka
Date : April, 2019

1. What is wrapping and unwrapping?


2. When to use class and when you use structure?
3. What is stored property and what is computed property?
4. What is lazy property?
5. How to remove duplicates from the array?
6. How print third position value from the array?
7. Which methods called when one view controller is popped from navigation
controller?
8. Explain optionals.
9. What is strong and what is weak? When you will use strong and when you will use
weak?
10. Explain view controller life cycle.
11. Enlist Table view delegate methods.

Asterika Infotech iOS Interview Questions


Location : Sion, Mumbai, Maharastra
Date : April, 2019

1. What is binding and what are the types of bindings?


2. What’s new in swift 5?
3. What is encapsulation, polymorphism, abstraction?
4. What is priority in constraints?
5. Explain process of push notifications.
6. What is size classes?
7. Difference between delegates and protocols?
8. Difference between obj c and swift?
9. Difference between strong and weak?
10. How to fetch user's current location in background?
11. Life cycle of viewcontroller?
12. Write code for protocols.
13. Life cycle of application.
14. How to install third party api without using pod and file drag drop?
15. What is thread?
16. What is gcd? Why we use?
17. Process to upload app on app store?
18. How you do unit testing from xcode?
19. Why we use mvc?
20. How will you implement all types of inheritance? Write code for individual.
21. Difference between soap and rest?
22. Difference between get and post?
23. How to store local data securely in phone?
24. What is NSOperation? How we use?
25. What are the database? Which one you choose? Why?
26. Benefits of FCM?
27. Difference between array and nsarray?
28. Difference between cocoa and cocoa touch?
29. What is string interpolation?

30. What is memory management?


31. How to identify how much memory is using your app?
32. Device token will be changed or not if we uninstall and reinstall the app ?

NeoQuant Solutions iOS Interview Questions


Location: Andheri,Mumbai, Maharastra
Date : May, 2019
Experience : 2-4 Years

1. Difference between nil and null.


2. What is the use of NSSet?
3. Process of how notification works?
4. What is the use of appid?
5. Why certificates required to upload the app on app store?
6. How to remove duplicates from array?
7. Sort strings in array (ascending order).
8. How to check nil keys in dictionary?
9. Difference between closure and blocks?
10. What’s new in swift 4.2 and swift 5?
11. What is the use of enumeration?
12. What is handshake process?
13. How to call api’s of “https”?
14. What is filter method?
15. Where certificates and provisional profiles gets installed?
16. What is the difference between internal testers and external testers in tesflight?
17. What is mlkit?
18. How to check nil value in dictionary’s where dictionary contains 10,000+ key value
pairs ?
19. What is .P12 and .Cer file?
20. What is endurl in payment gateway?

Infrasoft Technologies iOS Interview Questions


Location : Andheri, Mumbai
Date : June, 2019

1. What are oops concepts?


2. What is abstraction?
3. What is difference between abstraction and encapsulation?
4. What is entry point of iOS Application?
5. Is there any main file is available in swift?
6. Application state
7. When I get a phone call when app is in foreground, in which state, app goes?
8. What is difference between assign and retain?
9. What are design pattern?
10. Which design pattern are you using?
11. In mvc, is there direct communication between view and model?

12. We are not getting response from api after much time and loader is still shown, how
can you handle this?
13. Why SOAP is more secure than REST?
14. Response is in which format in SOAP and in REST?
15. Do you know different background modes? i.e push notification, location, bluetooth,
audio play
16. Do you know optional in swift?
17. How push notification works?
18. What is use of reduced in higher order function?
19. What is new in xCode 10.2?
20. If you wanna go to another branch for doing some work, and after some time you
wanna come back to your previously saved work, how you can manage in GIT?
21. Design iphone landscape, how you go with it?
22. What is frame and bounds?
23. How you can add column in entity in core data that can be also added in next
release?
24. What is ssl pinning?
25. What you are using for giving security of data in your app?

GOQII iOS Interview Questions


Location : Govandi, Mumbai
Date : June, 2019

1. What is difference between swift and objective c?


2. Difference between Swift 3 and Swift 4?
3. What is your role in developing application?
4. What are architecture of your file structure in xCode?
5. What is alternate of Alamofire in swift?
6. How you get response in your viewcontroller from alamofire api call?
7. What is use of closure?
8. What is layer in core data?
9. Difference between NSOperation and GCD?
10. Why delegate is weak?
11. Difference between delegate and protocol?
12. How apple push notification works?
13. How device token is generated?
14. How app will launch while tapping on app icon?

OneKosmos iOS Interview Questions


Location : Mumbai
Date : June, 2019

1. What are steps to manage memory?


2. How should I give priority to give strong or weak reference?
3. How do you find memory leakage in your app?

4. VCA and VCB. There is one strong reference from VCA to VCB, then what happen
if VCB will be dismissed?
5. Can I have corner radius with shadow to view in swift?

Reliance Mutual Fund iOS Interview Questions


Location : Mumbai, India
Date : May, 2019

1. From where you get tracker data?


2. How do you fetch data in every 10 seconds from server?
3. Are you calling API or any push mechanism for getting tracker data?
4. How Uber, ola working for tracking data?
5. For API call, what you are using?
6. How you parse response from alamofire api call?
7. What is use of swiftyjson?
8. Do you know about encodable & decodable?
9. Can we use encodable & decodable class instead of swiftyjson?
10. What are other options for calling API instead of alamofire?
11. Different type of task nsurlsession perform?
12. What is closure in swift?
13. In objective c, how can avoid crashing of app?
14. What is if let & guard let?
15. If I don't write return in guard statement, what would happen?
16. What basic things required for put any uiview for position?
17. What is size class?
18. How many constraints must be applied on uiview?
19. How constraints internally worked?
20. How to import alamofire to your project?
21. What is Cocoa pods for?
22. How apns works?
23. What are steps to deploy app to appstore?
24. How to release app to testflight?
25. What are design pattern in iOS?
26. What is delegation pattern?
27. What is callback function?
28. How you show loader while calling api in swift?
29. How to cancel alamofire api request?
30. Have you used MVVM?
31. How you show current location blue dot on map?
32. What is nszombie?
33. What is GCD?
34. Difference between DispatchQueue and DispatchGroup
35. What is difference between struct and class?

Netwrok18 Interview Questions


Method : Telephonic
Date : August, 2018

1. Difference between guard and if let. Which one is better to use?


2. How to implement core data in your project step by step? What if I have not select
checkbox for core data while creating project?
3. What is lazy keyword?
4. What is lazy loading?
5. What is closure? When do we use closure?
6. What is delegate? How we can create delegate?
7. What is NSNotification?
8. Difference between KVO and KVC.
9. What is GCD?
10. What are difference type of Queues in GCD?
11. Difference between GCD and NSOperationQueue.
12. What does alamofire use internally?
13. In which case, we user NSOperationQueue?
14. Lifecycle of APNS
15. What are difference design pattern? Which are you using?
16. Lifecycle of UIViewController.

Emproto Technologies Interview Questions


Location : Bengluru, Karnatak
Method : Telephonic
Date : August, 2019

1. What is disadvantage of apple map kit?


2. What types of api provided by MapMyIndia?
3. What are SOLID principles?
4. What are OOPS Concepts? Explain all.
5. Which are run-time polymorphism and compile-time polymorphism?
6. Does swift supports method overloading?
7. Difference between Class and Struct?
8. What is closure in Swift?
9. Can we use weak for closure?
10. What are extension? Difference between category in Objective C and extension
Swift?
11. What is protocol extension?
12. What is protocol?
13. What are optional? How can we unwrap optional value?
14. What are optional binding? What are optional chaining?
15. What is difference between guard let and if let?
16. What is concurrency management and How we can handle it?
17. What is IBDesignable and IBInspectable?

18. What is content hugging priority and content resistance priority? Difference
between them.
19. What is encodable?
20. What is Core Data Stacks?
21. What is delete rule in Core Data?
22. How can you achieve memory management in Swift?
23. Have you ever used strong and weak reference in your project and Why?
24. Which design pattern have you used?

Bruviti Pune iOS Interview Questions Answers


Location : Pune
Date : October, 2019
Experience : 3-5 Years

Bruviti (Predictive Analytics)


Another name : K2

1. OOPS Concept.
2. Difference between encapsulation and abstraction.
3. How we achieve encapsulation and abstraction in iOS?
4. Write code for creating custom protocol?
5. How class confirm protocol in objective c and swift?
6. Application life cycle
7. Difference between background state and suspended state.
8. How much time code can be executed in background? What will occur after that?
What If I download something that can takes much time, what will be occur?
9. Which inheritance objective c support?
10. What is base class?
11. View Controller life cycle.
12. How many times Viewdidload and layoutsubviews called?
13. Which method will first called if I came from back button?
14. What will occur if I have tableview in uiscrollview, if I scroll?
15. What is UIResponder Chain?
16. What are UITextField delegate methods?
17. Which method called when I click on next, done button?
18. How cellForRowAtIndexPath methods works?
19. What is dequecellreusablecellidentifier? What are overloading of deque methods?
What are purpose for both?
20. What is GCD?
21. How we can achieve concurrency type in Objective C and Swift?
22. What is auto-release-pool?
23. What is ARC?
24. How APNS works?
25. What is RICH Notification?
26. Which design patterns are there?
27. What is MVC?
28. What is Singleton pattern?

Leap and Scale iOS Interview Questions Answers


Location : Pune
Date : October, 2019
Experience : 3-5 Years

1. Which location you used for current location, network location or gps location?
2. What is accuracy of GPS location?
3. How you will calculate for geo fencing in your mobile app?
4. Have you done battery optimization for gps or api calling?
5. What is polymorphism?
6. What is exception?
7. What is error?
8. Difference between error and exception?
9. Why it is require to handle exception?
10. Difference between asynchronous and synchronous calls.
11. How you have used async task?
12. Which are methods of async task? 4 Methods.
13. What is multithreading?
14. Which are methods of threads in Swift?
15. Difference between thread methods start and run>
16. What is difference between REST and SOAP api? Why SOAP is more sequre?
17. What methods of REST? GET, POST.
18. What are other methods rather than GET and POST?
19. Difference between GET and POST?
20. Difference between Core Data and Sqlite?
21. Why you use swift rather than Objective C?
22. What they signify? ?, ??, !!
23. Application Life cycle.
24. Difference between Inactive and Suspended.
25. Difference between Background and Inactive.
26. What is Singleton? Write code.
27. Write a program for sorting array. Quick sort, merge sort, Heap Sort
28. Write a program for get only numeric from "a,b,1,2,c,4,d,3"
29. Swap between two numbers without third variable?

Wipro iOS Interview Questions


Location : Pune (Telephonic)
Date : October, 2019

1. What are pillars of oops?


2. What is abstraction example in ios?
3. What is syntax of singleton class? How we can create singleton class?
4. What is subscript? Give example of use.
5. Difference between if let & guard let.
6. What is initializer? What are different types of initializer? Can we have multiple I
initializer?
7. What is different way for serializing Jason or parsing Jason?

8. What is latest technique to serialize?


9. What are MVVM and VIPER?
10. What is technique in ios to secure your api call?
11. How can I call 6 api simultaneously? Tell steps for this?
12. How arc works in ios?
13. How to create retain cycle? How to solve this?
14. Difference between weak & unknown?
15. When you to use structure and when to class?
16. Different types of size class?
17. How will you design for iPhone and iPad design?
18. Have you use higher order function?
19. Difference between map and compact map?

XEBIA IT iOS Interview Questions


Location : Mumbai (Telephonic)
Date : October, 2019

1. How you setup for push notifications?


2. Which architecture you are using in your project?
3. How to do json serialised in Swift?
4. What is encodable and decodable?
5. Are you using any library for otp verify if login is using Mobile number?
6. Explain OOPS concept?
7. If you want to add methods for any class, if source available or not, how you can
achieve?
8. What is delegate?
9. Why delegate is weak?
10. What are generics in swift?
11. How to save data in core data?
12. Difference between Struct and Class.
13. How memory allocated for struct? Compile time or dynamic time?
14. Which is faster, class or struct?
15. What is MVVM?
16. What is other patterns you used apart from MVC?
17. What is protocol extension?
18. What is the different control transfer keyword in Swift?
19. Difference between Break and Continue?

Drona HQ iOS Interview Questions


Location : Mumbai
Date : September, 2019

1. What is content hugging Priority?


2. How to call segue through coding?
3. If I want to show image on push notifications?
4. How we can add button or action on push notifications?
5. Can you search your app content In spotlight (search bar)?

6. 5 Ltrs jar & 3 Ltrs jar, I want to add 4 Ltrs in another jar, How can I?
7. What is code signing?
8. What information provisioning profile has?
9. What app Id include?
10. What is app group capability?
11. What is universal linking? If I click on link of flippant, it open specific product,
what it is?

Globant iOS Interview Questions


Location : Pune
Month : Feb, 2020
Experience : 5+ Years

Screening :

1. Difference between struct and class?


2. Access modifiers in Swift.
3. Features that is in Swift but not in Objective C.
4. Different task available in NSURLSession?
5. What are content hugging and resistance priority?
First Round (Swift Only):
1. How to get value from optional?
2. Difference between struct and class.
3. Is it possible to declare array with nil like [1,2,3,nil,5,6]
4. How to do sum of above array using higher ordered function? Write program for
that.
5. Can you write singleton class in swift?
6. What are access specifier in swift? Which one is default access specifier?
7. Difference between Open and Public.
8. How to use pass by reference as parameter of function?
9. What is subscript?
10. Can you define closure, which take string, return integer, count characters and return
count?
11. What is closure?
12. Can I replace closure in place of function or function in place of closure?
13. Difference between closure and function? Can I pass function as parameter of
another function?
14. Why swift is considered as protocol oriented language? What are new features in
protocol due to swift considered as Protocol oriented language?
15. Write a code for calling rest api to fetch data from api using NSURLSession and for
Codable protocol confirmed struct?
16. What is protocol extension?
17. What is property observer?
18. What is design patterns? How many types of design patterns are there?
19. Difference between encapsulation and abstraction.
20. Difference between objective c and swift protocol
21. How to write unit testing code in Xcode?

22. What is generics? Write a program to make and use generics.


23. Make different design for portrait and landscape in Xcode.

2nd Round :
1. What are new features in swift 5?
2. What is ABI Stability?
3. What is app thinning and why it has more power in new swift 5?
4. What are source, version, binary type compatibility?
5. Is there possibility for interoperability between objective c and swift? What are
things which are not interoperable between swift and objective c?
6. What is bridging header?
7. Is it possible to code written in swift is interoperable in objective c?
8. Have you worked with dependancy manger, Carthage, cocoa pods?
9. When we use pod deinit?
10. What will happened if I delete pod.lock file?
11. How to upload framework to cocoa pods?
12. Which cocoa pods version you are using?
13. Which access modifier you will use if you want to expose methods to different
module? -Open, Public
14. Difference between public or open?
15. What is internal access specifier?
16. How to use decoder and encoder ? How to map your model class struct with json
data?
17. Is it mandatory keep name of your struct para name same as json data?
18. Can we declare optional methods in swift protocol? That protocol can be used for
classes and structure both?
19. Is objective-C support struct?
20. What is SSL pinning?
21. Can we store object in user default?
22. What are best way to implement if large data is coming from core data and show
data on tableview?
23. Difference between collection view and tableview?
24. What are different delegate and datasource for UICollectionView?
25. Is ARC for swift or iOS?
26. Is outlet should be weak or strong?
27. What is capturelist in closure? Why to need mention [weak self] in closure?

Angel Broking iOS Interview Questions


Location : Andheri, Mumbai
Date : Feb, 2020

1. What are major features coming in swift 5?


2. What is scene delegate?
3. Application lifecycle.
4. ViewController lifecycle
5. Difference between objective c and swift
6. Why swift is considered as Protocol Oriented language?

7. Difference between class and struct.


8. What will happened, if I write var strcut2 = strcut1, retain count of strcut1 will be
increased or not?
9. Difference between coredata and sqlite.
10. What is closure?
11. What is capture and capture list in closure?
12. Higher ordered function of array?
13. What is map function in swift?
14. What is way to make optional method in swift protocol?
15. Tell me about Generics.
16. Describe APNS Cycle.
17. What is payload size?
18. What is happened with push notifications if device has not internet connection?
19. Push notification stored in apple system in sequential format or what?

Welldoc iOS Interview Questions


Location : Bengaluru
Mode : Telephonic
Date : Feb, 2020

1. Have you managed security for data passing?


2. Have you used for security like ssl pinning?
3. Which encryption you have used for data passing? 3DES is symmetric or
asymmetric?
4. Data encryption and decryption will be slow or fast? How?
5. First time who sending key for encryption and decryption? Server or mobile app?
6. What you have done for battery optimization while GPS is on?
7. Can you explain SOLID principle?
8. Can you tell me about how many design patterns are there?
9. Can you explain singleton design pattern?
10. Can you explain OOPS concept?
11. What is .dysm file?
12. What is difference between sqlite and core data?
13. What is firebase real time database integration?
14. Can you explain multithreading? How we can achieve in iOS?
15. What is difference between GCD and OperationQueue?

Synchronoss Technologies Inc.


Location : Banglore
Date: March, 2020

1. When required init method is mandatory? What is that?


2. What will happen if we put weak and strong in capture list in closure?
3. Difference between strong and weak reference?
4. How we stop notification to be sent to device who is uninstalled?
5. What is better, Force unwrapping or optional binding?

6. How we can use structure made in Objective-c made in swift?


7. What is assembler?
8. How to solve git problem, if I pull before friend push code, what will happen?
9. What is dependency injection?
10. Why mvvm is required to be introduced?
11. Difference between class and structure?
12. Difference between structure and enum?
13. What is compile time polymorphism and runtime polymorphism?

Jet Synthesis iOS Interview Questions


Pune, Maharastra
Date : March,2021

1. What you do for battery management in your app while using GPS?
2. Which method of URLSessoin you can use to get data from REST api?
3. How can I be notified if all my api running in parallel will be completed its
excecution?
4. How we make sure all my api running parallel?
5. What are advantages of NSOperation over GCD?
6. Difference between class and struct
7. How to retain cycle occurs?
8. How do I find retain cycle? How to use instrument to check retain cycle?
9. What is unwind segue?

LnT Infotech iOS Interview Questions


Pune, Maharastra
Date : March, 2021

1. Write MVVM file structure.


2. How ViewController interact with ViewModel?
3. How pass data from ViewModel to ViewController?
4. Can we take ViewModel as Struct instead of Class?
5. Difference between struct and class.
6. Is there any way to achieve inheritance in struct?
7. Can we write computed and stored properties in Protocol?
8. How many types of closure are there?
9. Difference between escaping and non escaping closure?
10. Closure having capture list is escaping or non escaping closure?
11. Is any other class initialized in any viewcontroller has strong or weak?
12. How many types of acces specifier in Swift?
13. Difference between Open and Public.
14. Difference between Weak and UnOwned.
15. What is use of defer keyword?
16. If there are 4 defer statements, then how it will be excecuted?
17. How and what we will test in MVVM ?
18. What is Swift package manager?

Moofwd iOS Intreview Questions


Location : Mumbai
Date : March, 201

1. What is push notification payload maximum size?


2. Can I send payload more 4 kb?
3. How we use notification extension and what is purpose of it?
4. Difference between Objective C and Swift.
5. Where main class exist in swift project?
6. Difference between let and var.
7. Can we declare variable in Swift protocol?
8. Difference between Delegate and Notification.
9. Difference between NSOperationQueue and GCD.
10. What is purpose of dispatch group?
11. Difference between content hugging priority and content compression priority

Futurism Technologies iOS Interview Questions


Location : Pune
Date : March, 2021

1. Have you used in SwiftUI?


2. What is CI/CD?
3. What is dependency injection? What is reason to do dependency injection?
4. What is advantage and disadvantage of dependency injection?
5. What is singleton pattern?
6. What is disadvantage of singleton pattern?
7. What is defer? If method having 2 defer block, which one defer block will be
executed?
8. What is optional chaining?
9. What is subscript?
10. What is use of optional binding?
11. Why swift is called protocol oriented?
12. Difference between object oriented language and protocol oriented language?
13. Difference between class and struct.
14. Give example where we should make struct.
15. What is type of closure?
16. What is use of closure?
17. What is trailing closure?
18. What is use of escaping closure?
19. What is auto closure?
20. What is type method?
21. Difference between method and function.
22. What is type property?
23. Difference between type method and class method?
24. What is mutating method?
25. Why mutating in class is not good practice?

26. What is lazy property?


27. Is lazy property is let or var?
28. What is retain cycle?
29. IS delegate is weak or strong?
30. What is category?
31. Is it possible to add property in category?
32. When we can use extension in Objective-C?
33. What is KVC and KVO ?
34. How you implement KVO in swift ?
35. How you implement KVO in Objective C?
36. Difference between Objective C and Swift ?
37. What is atomic and non atomic property?
38. Have you used vision framework?
39. What is remote config in firebase?

TCS iOS Interview Questions


Location : India
Date : March, 2021

1. Difference between Swift and Objective C.


2. What is protocol oriented languages?
3. Difference between OOPS and POPS ?
4. What are higher order function?
5. Difference between map and flat map?
6. What is compact map?
7. Difference between MVC and MVVM.
8. What is optional?
9. What is optional binding?
10. Difference between if let and guard let.
11. What are application states?
12. How to run our application continuously running in the background?
13. What is lazy?
14. What is weak and unowned?
15. Difference between KVO and Delegate.
16. What are solid principles?
17. Difference between GCD and OperationQueue?
18. Difference between escaping and non-escaping closure.
19. What is codable?
20. How to upload your own framework to cocoapods?
21. How can you move from 4 commits to one commit?
22. What is git squash?
23. What is rebase in git?
24. Difference between management and leadership skill.

Location: Bangalore
Date: March, 2021

1. What are application states?


2. Can you co-relate app delegate methods with app states?
3. Difference between Strong and Weak.
4. Difference between Class, Structure, Enum.
5. What is protocol-oriented program?
6. What is optional binding in Swift?
7. What are constraints?
8. What are map and compact map?
9. Difference between compact map and Flat map
10. How to switch from background queue to main queue?
11. What is a serial queue?
12. What is a concurrent queue?
13. How agile methodology works?
14. Why you use FCM notification instead of APNS?

IVY Compact iOS Interview Questions


Location : Hyderabad
Date : Aug, 2021

1. Difference between Static and Class.


2. Difference between Static Dispatch and Dynamic Dispatch.
3. Explain Solid principles with examples.
4. What are higher order function?
5. What are new in Swift compare to Objective C.
6. What is protocol-oriented program?
7. What are map and compact map?
8. How to split this array [0, 1, 2, 0, 1, 2] to subarray off 0,1,2?
9. Can you draw high level diagram of file download.
10. Can you draw high level diagram of image library.
11. Difference between Swift and Objective C.

1-What is an iOS application and where does your code fit into it?
2-Whats fast enumeration and struct?
3-Explain View Controller Lifecycle events order ?
4-What are mutable and immutable types in Objective C?
5-Dispatch Barriers and Dispatch group in Swift 3
6-What is FRP (Functional Reactive Programming) and what are the options for
laying out UI frame and bounds on iOS?
7-Is a delegate retained and What is dynamic?
8-Outline the class hierarchy for a UIButton until NSObject.
9- Do you code review and/or pair program?
10-WHAT’S NEW IN XCODE 12
11-How to change the Application Name?
12-Whats the NSCoder class used for?
13-What is SpriteKit and what is SceneKit?
14-What is git stash and what is the function of ‘git stash apply’?
15-What is git reflog and Web hooks?
16-What will be output for below code.
17-What are the App states. Explain them?
18-Multitasking support is available from which version?
19 .What is Automatic Reference Counting (ARC) and How is memory
management handled in iOS?
20-iOS life cycle.
21.What is the Responder Chain?
22-What is the difference between delegates, notifications, KVC, KVO and
Notification Center?
23-What is posing in iOS?
24-What is atomic and nonatomic? Which one is safer? Which one is default?
25-What are the tools required to develop iOS applications and where can you test
Apple iPhone apps if you don’t have the device?
26-How do you manage dependencies?
27- Name the framework that is used to construct application’s user interface for iOS.
28-Name a few Git commands and explain their usage?
29- Which API is used to write test scripts that help in exercising the
application’s user interface elements and Do you have TDD experience? How
do you unit and UI test on iOS?
30-How would you securely store private user data offline on a device? What other
security best practices should be taken?
31-Codable Protocol
32-Why is JIRA used?
33-Consider the following code:
34-What is the use of SwiftLint in iOS?
35- What is Zendesk?
36-What is Jenkins?
37-Consider the following code:
38- What is the difference between Continuous Integration, Continuous Delivery,
and Continuous Deployment?

39-iOS 15 All the new features


40-Traits and Size Classes in iOS?
41-Who calls the main function of you app during the app launch cycle?
42-What is the use of controller object UIApplication?
43-What is the difference between rebase and merge in Git?
44- Which app specific objects store the app’s content?
45-Explain static and dynamic library/framework in iOS?
46- Common reasons for app rejection from App store review process?
47- Which is the super class of all view controller objects?
48-What is the purpose of UIWindow and View object?
49-How to call Objective-C code from Swift.
50-Apart from incorporating views and controls, what else an app can
incorporate?
51-Difference between Unlocking and jailbroking in iPhone Explain its?
52-Define property, synthesised and instance variable?
53-How and when to serialise, parse and map data on iOS?
54-Which are the protocols used in table view and What is the reuseIdentifier used
for?
55-What options do you have for implementing storage, database and persistence on
iOS?
56-What is the major purposes of Frameworks and tell four frameworks used in
iPhone?
57-What is the instance method, class method and accessor methods?
58-Difference between shallow copy and deep copy?
59-How to optimise scrolling performance of dynamically sized table or collection
views?Can we use two tableview controllers on one view controller?
60-Swap the two variable values without taking third variable?
61-Determine the value of “x” in the Swift code below. Explain your answer.
62- InApp purchase product type
63-What is the navigation controller and split view controller?
64-The following code snippet results in a compile time error:
65-What is mean by App Thinning.
66-What is Cocoa and application Kit/App kit.
67-Selectors, Dynamic and Static Typing.
68-What are design patterns besides common Cocoa patterns that you know?
69-Class Introspection
70- Proxy
71- Why category is better than inheritance?
72- Formal vs informal protocol and Optional vs required.
73-Which is faster: for a search an NSArray or an NSSet?
74-alloc vs new vs Copy vs assign vs retain vs mutableCopy
75-What is Sandbox in iPhone ?
76-Coredata
77- Event Loop
78-What will be the output for below code.
79-What is the difference Stack and Heap ?

80-Collection
81-What is Deep Linking, HealthKit, Neural networks with Core ML?
82-.Can you spot the bug in the following code and suggest how to fix it:
83-What will be the output for below code.
84-What is the use of ? , ??, ! , Downcasting, zip?
85-What is Helper Objects and Cluster Class?
86-What is generics and the difference ANY and ANY OBJECT ?
87-Differentiate Foundation vs Core Foundation
88- Readers-Writers
89-Retain cycle or Retain loop.
90-What’s your preference when writing UI’s, Xib files, Storyboards or programmatic
UIView?
91-strong, weak, unsafe_unretained, autoreleasing, NSAutoReleasePool, release and
drain?
92-What is AutoLayout? What does it mean when a constraint is "broken" by iOS?
93-A product manager in your company reports that the application is crashing. What
do you do?
94-What makes React Native special for iOS?
95-Consider the following code:
96-How should one handle errors in Swift?
97.Should I learn Swift or Objective-C and Differences Between Swift And
Objective-C?
98.Subclass, Category and Extensions in Objective C
99. What is an API
100.What is the biggest difference between NSURLConnection and NSURLSession?
101.Explain and show examples of SOLID principles?
102.What is data encapsulation, Polymorphism and Abstract?
103.Swift’s Equitable and Comparable Protocols
104. Mention what is the characteristics of Switch Enums in Swift?
105.What is method swizzling in Objective C and why would you use it?
106.how to check crash reports client in iOS app?
107.Property Observers
108.Higher order functions in Swift?
109.Apple Push Notification Services?
110.What is Concurrency and Objectives of Concurrency?
111.Operations, Operation Queue and Grand Central Dispatch synchronous versus
asynchronous connections.
112.What considerations do you need when writing a UITableViewController which
shows images downloaded from a remote server?
113. Difference between struct and class swift
114. What are some ways to support newer API methods or classes while maintaining
backward compatibility?
115. In Swift, what are fail-able, throwing initialisers and Tuples?
116. What is an “app ID”, “bundle ID” , App Bundle and Signing?
117. if let, if var, guard let, guard var and defer statements in swift
118.Please explain Access Levels in Swift?
119. networking, Get, Post, REST, HTTP, HTTPs, JSON  What’s that?

120.List out what are the control transfer statements used in Swift?
121.What is Property?
122. What are the most important application delegate methods a developer should
handle ?
123. How do you debug and profile code on iOS?
124. What is three triggers for a local notification and use of UserNotifications?
125. nil / Nil / NULL / NSNull
126. What is the difference between functions and methods in Swift?
127.What are optional binding and optional chaining in Swift?
128. What's the syntax for external parameters?
129.Would you consider yourself a Swift expert?
130.What are blocks and how are they used?
131.What is the difference Non-Escaping and Escaping Closures ?
132.What is the difference SVN and Git ?
133.What is the difference between LLVM and Clang?
134.How many different ways to pass data in Swift ?
135. What kind of benefits does Xcode server and Xcode Bot have for developers ?
136.What are layer objects and Explain unwind segue?
137.How to convert Swift String into an Array?
138.why swift is protocol oriented language
139.What iOS architectures do you know that scale and design patterns are commonly
used in iOS apps, which one better for iOS Development?
140.New Build System in Xcode?
141.What’s new in Swift 5.0
142.Mobile Device Management (MDM) in iOS?
143.Which is testing framework is best?
144.How much test coverage is enough?
145.Should I unit test views and/or view controllers?
146.Doesn’t adding unit tests take more time?
147.setUp() And tearDown() in XCTest?
148.Designated Initialisers and Convenience Initialisers?
149.Local, Global and Static variables?
150.Which Inheritance will supports in Swift Single, Multiple or Multilevel?
151.Debugging skills in iOS
152.What difference between 'self' and ‘Self’?
153.What’s the difference between == and ===?
154.Write a Palindrome program
155.What is QualityOfService in operation?
156.Write a String reverse program
157.When would you use Swift’s Result type?
158.What is a UUID, and when might you use it?
159.What is the difference between the Float, Double, and CGFloat data types?
160.Types of ranges?
161.How would you explain Dynamic Type to a new iOS developer?
162.What is apple developer/enterprise account??
163.Difference between network location and gps location?

164.I have written for loop from 1 to 10. But when i=7 then then it comes out from
loop. I have not written any specific keyword nor exception generated. How it is
possible?
165.Difference between FCM and APNS?
166.Determine index of one integer in another integer - online programming question?
167.Write a program to find missing number of array of 1 to n?
168.Write a program to distinguish lowercase and uppercase character from String in
swift?
169.Can we make a class-specific protocol?
170.Can we declare an optional protocol method in swift?
171.Can we define property in extension?
172.Can we define property in protocol?
173.How we stop notification to be sent to device who is uninstalled?
174.What is p12 and pem file?
175.What are join in sql? Explain Types of Join?
176.Add column in SQLite?
177.If there are two views up and bottom, up-view is 60% of superview and 40% of
superview respectively, then what to do with constraint?
178.What is Content Hugging and Content Compression Resistance Priority?
179.What method is called after tap back button in ios?
180.What is StackView? What is advantage and distribution type of stackview?
181.Enlist different background modes?
182.How does CloudKit differ from Core Data?
183.What are the different ways of showing web content to users?
184.How much experience do you have using iBeacons? Can you give examples?
185.What are the advantages and disadvantages of SwiftUI compared to UIKit?
186.Can you talk me through some interesting code you wrote recently?
187.Do you have any favorite Swift newsletters or websites you read often?
188.How do you stay up to date with changes in Swift?
189.If you could have Apple add or improve one API, what would it be?
190.What books would you recommend to someone who wants to learn Swift?
191.What open source projects have you contributed to?
192.Have you ever filed bugs with Apple? Can you walk me through some?
193.What experience do you have working on macOS, tvOS, and watchOS?
194.What is the purpose of code signing in Xcode?
195.What steps do you take to identify and resolve battery life issues?
196.What steps do you take to identify and resolve a memory leak?
197.What steps do you take to identify and resolve performance issues?
198.How much experience do you have using Face ID or Touch ID? Can you give
examples?
199.How would you explain App Transport Security to a new iOS developer?
200.How would you calculate the secure hash value for some data?
201.In which situations do Swift functions not need a return keyword?
202.Apart from the built-in ones, can you give an example of property wrappers?
203.Can you give useful examples of enum associated values?
204.What are opaque return types?
205.How would you explain SwiftUI’s environment to a new developer?

206.What does the @Published property wrapper do?


207.When would you use @StateObject versus @ObservedObject?
208.What's the difference between a view's initializer and onAppear()?
209.How can an observable object announce changes to SwiftUI?
210.How would you create programmatic navigation in SwiftUI?
211.Why does SwiftUI use structs for views?
212.Modifiers/Custom modifiers in SwiftUI?
213. Containers in SwiftUI?
214.How to create stacks using VStack, HStack and ZStack?
215.What is trailing closure?
216.Differences between TCP and UDP?
217.Write a program to find largest number in array [1,2,3,5,8,6,9,7]?
218.What are the programming languages used for iOS development?
219.What is Operator Overloading?
220.How could you set up Live Rendering?
221.Explain Compilation Conditions?
222.What is Regular expressions?
223.What is TVMLKit?
224.How is an inout parameter different from a regular parameter?
225.Determine the value of X in the Swift code below. Explain your answer?
226.A grandparent, parent and child problem?
227.Find the bug in the Objective-C code below. Explain your answer?
228.Rewrite this code in a Swift way?
229.What are the projects you were involved in so far? What technologies did you use
there?
230.Are you involved in any open source projects? What is your role there?
231.How big were the teams? Have you been a leader in any of those projects?
232.What are the sources of your knowledge? Do you read any blogs or listen to any
podcasts? Name a few.
233.Have you worked with Scrum/Agile? What do you think about that? When in
your opinion it can be good and when rather harmful?
234.What is your opinion on Code Review?
235.Do you go to conferences and local meetups sometimes? Do you have any favorite
one?
236.Consider two input arrays,
let listOne = [3,nil,5,7]
let listTwo = [4,6,2,8,nil]
By using high order functions, write code snippet to get a sum of all integers from both
Arrays?
237.Bob developed an iOS application, uploaded on store successfully. Since he is
working for client XYZ, he chooses bundle-id com.xyz.appName for this music
application. But the later name of the organization changed now the client wants to
update bundle-id too.What are the possible ways to handle this?
238.For your photo-gallery iPad application, What would be your preference as senior
developer, Alamofire or URLSession?
239.Almost all companies are taking the subject of data security and privacy severely.
So how to protect user's sensitive data in iOS applications.?

240.What will be output for below code snippet? Also, analyze the memory
performance for this code?
241.What is the difference between the consumable and non-consumable type of in-
app purchase?
242.Swift is a static language and Objective-C dynamic language. What does it mean?
243.What is the output of the following Program? let numbers = [1, 2, 3, 4]?
244.Structures can be inherited(True/False)?
245.What is the Output of Following Program var randomly Array: [AnyObject] =
[1,1.2,”Hello”] print (randomArray)?
246.What is the Output Of Following Program?
247.Is it possible to create multiple storyboards in single project. If yes how to switch
from one storyboard to another?
248.what are binaries required to install the app to device?
249.How much will you rate yourself in iOS?
250.How much experience do you have in iOS?
251.Have you done any iOS Certification or Training?
252.what OAuth?
253.Why Choose Struct Over Class?
254.Combine Framework in iOS?
255. Publishers in Combine Framework?
256. Operators in Combine Framework?
257. Subscribers in Combine Framework?
258.Static vs Dynamic Dispatch in Swift?
259.Static and Class Keyword in Swift?
260.How to split this array [0, 1, 2, 0, 1, 2] to subarray off 0,1,2?
261.I didn't hear back immediately after my interview. Am I rejected?
262.Can I re-apply to a company after getting rejected?
263.Why do you want to work for Microsoft?
264.How you will store user info (username, password or token) securely in iOS?

iOS Roadmap to Professional Developer

1-What is an iOS application and where does your code fit into it?
This is a big-picture question asked, in one form or another, to gauge your understanding of
what an iOS application is, and where the code you write fits in it and in the iOS system
overall.
We might think the apps we build are something special because they cover a unique use
case. But your typical iOS application is just a giant, glorified run loop. It waits for user
input and gets interrupted by external signals such as phone calls, push notifications, home
gestures/button presses, and other app life cycle events. The only difference is that instead
of being just a simple main loop function that gets launched every time the user taps on
your app icon, it has a higher level of abstraction, UIApplication, AppDelegate, and
SceneDelegate that developers work with.
The rest of the code you write to implement the business logic of your app is placed
somewhere in the “trigger points” delegated by that main loop to our app via AppDelegate
or SceneDelegate. Before iOS 13 AppDelegate was responsible for receiving all external
events for your application and spinning up the UI; but starting with iOS 13 all UI-related
logic was moved to SceneDelegate.
That’s it. Simple. The code you write for your app can be as simple as a method/function
call, or as complex as VIPER architecture. It’s your choice.
Typically developers think of iOS apps as the MVC code they write and the complex
intricate details of the implementation, which is true. But if you take a step back and look at
the big picture, you can see what iOS apps really are - a run loop.

2-Whats fast enumeration and struct?


Fast enumeration is a language feature that allows you to enumerate over the contents
of a collection. (Your code will also run faster because the internal implementation
reduces message send overhead and increases pipelining potential.)
A struct is a special C data type that encapsulates other pieces of data into a single
cohesive unit. Like an object, but built into C.

3-Explain View Controller Lifecycle events order ?


There are a few different lifecycle event
- loadView
Creates the view that the controller manages. It’s only called when the view controller is
created and only when done programatically.
- viewDidLoad
Called after the controller’s view is loaded into memory. It’s only called when the view
is created.
- viewWillAppear
It’s called whenever the view is presented on the screen. In this step the view has bounds
defined but the orientation is not applied.
- viewWillLayoutSubviews
Called to notify the view controller that its view is about to layout its subviews. This
method is called every time the frame changes
- viewDidLayoutSubviews

Apple gave a very good explanation on this by saying that it is called to notify the view
controller that its view has just laid out its subviews.
In another word, viewDidLayoutSubviews is called every time the view is updated, rotated
or changed or it’s bounds change.
But know that with viewDidLayoutSubviews, it only take places after all the auto layout or
auto resizing calculations on the views have been applied. Meaning the method
viewDidLayoutSubviews is called every time the view size changes and the view layout has
been recalculated.
- viewDidAppear
Notifies the view controller that its view was added to a view hierarchy.
- viewWillDisappear
Before the transition to the next view controller happens and the origin view controller gets
removed from screen, this method gets called.
- viewDidDisappear
After a view controller gets removed from the screen, this method gets called. You usually
override this method to stop tasks that are should not run while a view controller is not
on screen.

4-What are mutable and immutable types in Objective C?


Mutable means you can change its contents later but when you mark any object immutable,
it means once they are initialised, their values cannot be changed. For example, NSArray,
NSString values cannot be changed after initialised.
NSString *s = [[NSString alloc] initWithString:@"Hello"];
s = [s stringByAppendingString:@"World"]; and
other code like this
NSMutableString *ms = [[NSMutableString alloc] initWithString:@"Hello"];
[ms appendString:@"World"];
Both of these, functionally, do the same thing except for one difference - the top code block
leaks. -[NSString stringByAppendingString:] generates a new immutable NSString object
which you then tell the pointer s to point to. In the process, however, you orphan the
NSString object that s originally pointed to. Replacing the line as follows would get rid of
the leak:
s = [[s autorelease] stringByAppendingString:@“World”];

5-Dispatch Barriers and Dispatch group in Swift 3


Serial Queues
Tasks in serial queues execute one a time in first in first out format. Task1 has to finish for
Task2 to start. Task2 has to finish for Task3 to start and so on.
Concurrent Queues
Tasks in concurrent queues execute in any order and can start simultaneously. Below code
reads and writes to the dictionary concurrently. This is very fast compared to the above
serial queue. However, because we may be reading while writing at the same time, we will
run in to the readers-writers problem.
Using concurrent queues with barriers helps us improve and speed up our code while
eliminating the readers-writers problem, which is also important for singletons.
Dispatch group

A dispatch group lets us easily keep track of multiple blocks that have been dispatched to
queues and be notified when they are complete. They make things much simpler by
allowing us to not need to keep state of all the blocks that we have dispatched. Now it's not
desperately complicated to do so, we could just keep a count of how many blocks we have
dispatched, or an array of the dispatched blocks and decrement (or remove from the array)
on completion. Since this is such a common thing to do Apple have done this for is, it's
worth noting that this can be less simple to implement if we dispatch the same block
multiple times, or are dispatching blocks across several different queues.

6-What is FRP (Functional Reactive Programming) and what are the options for
laying out UI frame and bounds on iOS?
Functional reactive programming (FRP) is the new hotness in iOS/Swift, JavaScript, and
other dev communities. Except that it’s actually not that new. Expect this question either on
Swift features, or as a bigger architectural and conceptual discussion question.
Functional Reactive Programming (FRP) is a declarative programming paradigm that
combines functional programming and reactive (async data flow programming) paradigms.
It is a declarative style of programming where you declare what your code does rather than
state how it does it. The reactive component of FRP allows us to introduce and describe the
concept of time, which is hard to work with in pure functional programming. FRP helps us
deal with user input and the asynchronous nature of iOS applications in general; user input
happens at some point in time, networking will finish some time in the future, etc.
FP and FRP rely on higher-order functions such as map, reduce, and filter that take
functions as arguments and return other functions, which makes them highly composable.
Swift doesn’t have native support for FRP, but there are two excellent libraries that
implement functional reactive programming concepts and make them easily available to us:
ReactiveCocoa and RxSwift.
In iOS 13, Apple also announced a new FRP framework built into iOS called Combine.
Combine is effectively an FRP framework implementation similar to RxSwift. The two
advantages it has: it’s integrated with SwiftUI allowing it to bind UI elements to data
changes, and it’s built-in and supported by Apple. Disadvantages are: it’s less mature than
RxSwift and Apple will be slow to make changes and additions to it.
FRP is becoming more commonplace in iOS apps and will be used more with Apple's
official support of this programming paradigm with Combine. iOS developers should start
embracing it.
Knowing your options for laying out things on the screen is crucial when you need to solve
different UI challenges on iOS. This question helps gauge your knowledge about how you
put place and align views on the screen. When answering this question, you should at least
mention CGRect, Frames and, AutoLayout, and SwiftUI, but it would be great to mention
other options such as Texture (ASDK), ComponentKit and other Flex box and React
implementations on iOS.
Go-to options for laying out views on the screen are good old CGRect Frames and
AutoLayout. Frames, along with auto-resizing masks, were used in the past before iOS 6
and are not a preferred option today. Frames are too error-prone and difficult to use because
it’s hard to calculate precise coordinates and view sizes for various devices.
Since iOS 6 we have AutoLayout, which is the go-to solution these days and which Apple
prefers. AutoLayout is a technology that helps you define relationships between views,
called constraints, in a declarative way, letting the framework calculate precise frames and

positions of UI elements instead.With iOS 13, Apple introduced a new approach for laying
out views - SwiftUI, which is a declarative approach that supports FRP (functional-reactive
programming) data bindings with Combine. FRP and declarative UI are not new concepts,
but SwiftUI and Combine are new frameworks from Apple that support it. The declarative
nature of SwiftUI allows you to declare your UI elements very concisely and then later
through data bindings declare what parts of the UI, such as text labels for example, to
update upon what data model changes. In effect, it allows you to do what was already
possible with RxSwift before, but now with Apple frameworks.
There are other options for laying out views, such as ASDK (Texture), ComponentKit, and
LayoutKit, and some of them are more or less inspired by React and others solve layout A
synchronicity differently. These alternatives are good in certain scenarios when, for
example, you need to build highly dynamic and fast table views and collection views.
AutoLayout is not always perfect for that and knowing there are other options is always
good.
NOTE: we’ll see how SwiftUI proves itself solving complex UI problems and complex
async UI layout problems in the future, it’s a very new technology as of the time of this
writing.
Not mentioning at least AutoLayout and the fact that frames are hard to get right will be a
red flag for your interviewer. These days no sane person would do CGRect frame
calculations unless it's necessary (for example, when you do crazy drawings).
It won’t be a red flag yet, but mention SwiftUI and that this likely will be what Apple will
push on us in coming years.
The frame of a view is the rectangle, expressed as a location (x,y) and size (width,height)
relative to the superview it is contained within. The bounds of a view is the rectangle,
expressed as a location (x,y) and size (width,height) relative to its own coordinate system
(0,0).

7-Is a delegate retained and What is dynamic?


No, the delegate is never retained! Ever!
If I call performSelector:withObject:afterDelay: retained? Yes, the object is
retained. It creates a timer that calls a selector on the current threads run loop. It
may not be 100% precise time-wise as it attempts to dequeue the message from
the run loop and perform the selector.
Is the delegate for a CAAnimation retained:Yes it is!! This is one of the rare exceptions
to memory management rules.
You use the @dynamic keyword to tell the compiler that you will fulfil the API contract
implied by a property either by providing method implementations directly or at runtime
using other mechanisms such as dynamic loading of code or dynamic method resolution. It
suppresses the warnings that the compiler would otherwise generate if it can’t find suitable
implementations. You should use it only if you know that the methods will be available at
runtime

8-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

9- Do you code review and/or pair program?


Even though there are a lot of applications out there that we're built by solo developers, the
complexity of what apps do keeps increasing, demanding that a team of developers work on
it. Working in a team poses different challenges in terms of code maintenance,
collaboration, and knowledge sharing.
Pair programming is a practice where two developers work on the same task together on
the same machine (hopefully not sharing the same screen and keyboard and having two sets
off their own). The goal is to facilitate collaboration, discussion, code review, and QA right
where the code gets produced. This process makes knowledge transfer and architectural
discussions a common day-to-day thing, preventing people from siloing and becoming “an
expert” in a certain part of the code (what happens when that person leaves or gets sick?). It
also improves code quality because two sets of eyes are looking at the code as it’s written.
This process happens for two developers at the same time and is sometimes called
synchronous.
Pair programming is not for everyone and could be an exhausting process if people’s
personalities do not match. But nevertheless it is one of the most efficient collaboration
techniques in software development.
Code review is a similar process of collaboration and knowledge transfer, but unlike pair
programming, it doesn’t happen at the same time, and therefore it is asynchronous. With
code review, after a developer writes a piece of code or a feature, someone else on the team
has a look at it. The reviewer checks if the code makes sense and suggests changes and
refactoring to be done to improve it. That opens up an online or offline discussion about the
code, which is great. That transfers knowledge about that piece of code to other teammates
and helps catch bugs and design smells early on.
Code reviews are a less-involved type of collaboration that achieves much of the same
results as pair programming does. It also is an exercise in empathy where you’re giving
feedback to others on their work.

10-WHAT’S NEW IN XCODE 12


Swift & SwiftUI:
SwiftUI introduced developers to a modern UI framework that made it more intuitive than
ever to build sophisticated app UIs. In Xcode 12, SwiftUI comes with new features and
improved performance.
Document tabs:
Document tabs open any type of document, including logs, asset catalogs, and UI files, in a
lightweight editor tab.
Navigator font sizes:
The navigator now tracks the system setting for “Sidebar icon size” used in Finder and
Mail. You can also choose a unique font size just for Xcode within Preferences, including
the traditional dense information presentation, and up to large fonts and icon targets.
Code completion:
A new completion UI presents only the information you need, taking up less screen space as
you type. And completions are presented much faster, so you can keep coding at maximum
speed.
Redesigned organizer:

An all-new design groups all critical information about each of your apps together in one
place. Choose any app from any of your teams, then quickly navigate to inspect crash logs,
energy reports, and performance metrics, such as battery consumption and launch time of
your apps when used by customers.
Devices:
• The Add Device sheet in the Devices and Simulators window is now resizable.
• The Devices and Simulators window permits selecting multiple devices in the
navigator, so they can be unpaired together. This eases the removal of old records for
devices that are no longer in use.
Simulator:
• Simulator can display a simulated device in full-screen mode, or tile its window
alongside Xcode. Now enjoy split-screen mode with Xcode and Simulator side by
side.
Universal Apps:
• Xcode 12 is built as a Universal app that runs 100% natively on Intel-based CPUs
and Apple Silicon for great performance and a snappy interface.
• It also includes a unified macOS SDK that includes all the frameworks, compilers,
debuggers, and other tools you need to build apps that run natively on Apple Silicon
and the Intel x86_64 CPU.
• When you open your existing project in Xcode 12, your app will automatically get
updated to generate release builds & archives as Universal apps.
Store Kit (Local Test Environment);
• Xcode 12 supports testing in-app purchases (IAP) directly in Simulator or on a
connected device, using a new local StoreKit test environment.
• It means you can configure IAP information locally for testing, before setting it up in
App Store Connect and without a connection to App Store servers.
Debugging:
• When a process pauses at a breakpoint, Xcode displays the hit count for that
particular breakpoint location as part of the breakpoint’s annotation in the editor.
Example: “Breakpoint 1.1 (10)”, where 10 means that location 1.1 has been hit 10
times.
Swift Packages:
• You can now declare conditions for a Swift package’s target dependencies, such as
limiting the dependencies by the platform.
• Swift packages can now contain resources such as images, asset catalogs,
storyboards, and other files.
Playgrounds:
• Xcode Playgrounds can now import and use Swift packages and frameworks. Select
the Build Active Scheme checkbox in the playground’s File inspector and ensure that
the active scheme builds the package or framework target.
Project Editor:
• The Document Types, Exported Type Identifiers, and Imported Type Identifiers
panes support the new templated document icons in macOS 11.
Interface Builder:
• Find and Replace now includes matches in attributed string literals.
• Interface Builder now has a Current Date option for NSDatePicker.












11-How to change the Application Name?


If you need to change the name of the Application as it appears on the iPhone's home
screen, you need to do it in the Target configuration, not the project configuration.
Expand the Targets group in Xcode, then single-click the item under that. It should
share the name of your project, which is also the default name of the application that
gets generated.

Press command-I to bring up the Info window, then navigate to the Build tag. Set the
Configuration drop-down to read All Configurations, then look for a setting called
Product Name under the Packaging heading. Change that value to the name you
want for your compiled applications and, in the immortal words of Bugs Bunny:
Viola! Do a clean then build and your application will take on the new name.

12-Whats the NSCoder class used for?


NSCoder is an abstractClass which represents a stream of data. They are used in Archiving
and Unarchiving objects. NSCoder objects are usually used in a method that is being
implemented so that the class conforms to the protocol. (which has something like
encodeObject and decodeObject methods in them).

13-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.

14-What is git stash and what is the function of ‘git stash apply’?
Often, when you’ve been working on part of your project, things are in a messy state and
you want to switch branches for some time to work on something else. The problem is, you
don’t want to do a commit of half-done work just so you can get back to this point later.
The answer to this issue is Git stash.
Stashing takes your working directory that is, your modified tracked files and staged
changes and saves it on a stack of unfinished changes that you can reapply at any time.
If you want to continue working where you had left your work then ‘git stash
apply‘ command is used to bring back the saved changes onto your current working
directory.

15-What is git reflog and Web hooks?


The ‘reflog’ command keeps a track of every single change made in the
references (branches or tags) off a repository and keeps a log history of the branches and
tags that were either created locally or checked out. Reference logs such as the commit
snapshot of when the branch was created or cloned, checked-out, renamed, or any commits
made on the branch are maintained by Git and listed by the ‘reflog’ command.
Note: The branch will be recoverable from your working directory only if the branch ever
existed in your local repository i.e. the branch was either created locally or checked-out
from a remote repository in your local repository for Git to store its reference history logs.
This command must be executed in the repository that had the lost branch. If you consider
the remote repository situation, then you have to execute the reflog command on the
developer’s machine who had the branch.

command: git reflog


Web hooks allow external services to be notified when certain events happen within your
repository. (push, pull-request, fork)

16-What will be output for below code.

print(“Apple”)
DispatchQueue.main.async{
print(“iPod”)
DispatchQueue.main.async{
print(“iPhone”)
}
DispatchQueue.global().sync{
print(“iPad”)
}
DispatchQueue.main.sync{
print(“Mac”)
}

print(“Apple Watch”)
}
print(“Apple TV”)
First, it will print “Apple”.
Next logic is contained in a 'main' async event. So it's postponed. The next thing it will print
is "Apple TV". Once the main thread is free, our first main.async task will run. So “iPod”
will print.
Next to its main.async task again. For this to execute, the main thread needs free. Since
we're still in the middle of the control flow, It will move to DispatchQueue.global().sync.
Read carefully, that it's dispatching sync not async. That means that the main thread is
frozen until the code dispatched to the global queue is done.Then it will print “Apple
Watch”. DispatchQueue.main.sync will crash app.

17-What are the App states. Explain them?


• Not running State: The app has not been launched or was running but was
terminated by the system.
• Inactive state: The app is running in the foreground but is currently not receiving
events. (It may be executing other code though.) An app usually stays in this state
only briefly as it transitions to a different state. The only time it stays inactive for
any period of time is when the user locks the screen or the system prompts the user
to respond to some event, such as an incoming phone call or SMS message.
• Active state: The app is running in the foreground and is receiving events. This is
the normal mode for foreground apps.

• Background state: The app is in the background and executing code. Most apps
enter this state briefly on their way to being suspended. However, an app that
requests extra execution time may remain in this state for a period of time. In
addition, an app being launched directly into the background enters this state
instead of the inactive state. For information about how to execute code while in
the background, see “Background Execution and Multitasking.”
• Suspended state:The app is in the background but is not executing code. The
system moves apps to this state automatically and does not notify them before
doing so. While suspended, an app remains in memory but does not execute any
code. When a low-memory condition occurs, the system may purge suspended apps
without notice to make more space for the foreground app.

18-Multitasking support is available from which version?

iOS 4 and above supports multi-tasking and allows apps to remain in the
background until they are launched again or until they are terminated, left side
diagram for iOS 4 and above and right side diagram for iOS 3 and below.

19 .What is Automatic Reference Counting (ARC) and How is memory


management handled in iOS?
ARC evaluates the lifetime requirements of your objects and automatically inserts the
appropriate method calls at compile time.Almost all the time you don't have to worry
about the memory management. It's done for you automatically. Objects just exist when
you need them and vanish when you don't. But there are 2 very common cases when you
need to be careful and think about memory.
1. Delegation. It's common pattern in Cocoa and it could create retain cycles if
done wrong. Always declare your delegate as weak unless you have a good
reason not to.
2. Closures. Closure capture references for objects in surrounding scope and does
it automatically, without notice. When implementing closure, check if it will
create retain cycle. If yes, declare problem variables as weak or unowned.
You should only use unowned when you are sure, that this variable will never be accessed
after the corresponding instance has been deallocated.

However, if you don’t want the variable to be weak AND you are sure that it can’t be
accessed after the corresponding instance has been deallocated, you can use unowned.
By declaring it [weak self] you get to handle the case that it might be nil inside the closure
at some point and therefore the variable must be an optional. A case for using [weak self] in
an asynchronous network request, is in a view controller where that request is used to
populate the view.
Memory management is very important in any application, especially in iOS apps that have
memory and other hardware and system constraints. This question refers to ARC, MRC,
reference types, and value types.
Swift uses Automatic Reference Counting (ARC). This is conceptually the same thing in
Swift as it is in Objective-C. ARC keeps track of strong references to instances of classes
and increases or decreases their reference count accordingly when you assign or unassigns
instances of classes (reference types) to constants, properties, and variables. It deallocates
memory used by objects whose reference count dropped to zero. ARC does not increase or
decrease the reference count of value types because, when assigned, these are copied. By
default, if you don’t specify otherwise, all the references will be strong references.
This is a must know for every iOS developer! Memory leaks and app crashes are all too
common due to poorly managed memory in iOS apps.

20-iOS life cycle.


CORE OS - The kernel in iOS is based on a variant of the same basic Mach kernel that is
found in
MacOS X.

CORE OS and CORE SERVICES LAYERS - These interfaces are mostly C-based and
include technologies such as Core Foundation, CFNetwork, SQLite, and access to POSIX
threads and UNIX sockets among others.

MEDIA LAYER –The Media layer contains the fundamental technologies used to support
2D and 3D drawing, audio, and video. This layer includes the C-based technologies
OpenGL ES, Quartz, and Core Audio. It also contains Core Animation, which is an
advanced Objective-C based animation engine.

COCOA TOUCH
In the Cocoa Touch layer, most of the
technologies use Objective-C. The frameworks at these
layers provide the fundamental infrastructure used by
your application. For example, the Foundation
framework provides object-oriented support for
collections, file management, network operations, and
more. The UIKit framework provides the visual
infrastructure for your application, including classes for
windows, views, controls, and the controllers that manage those objects. Other frameworks
at this level give you access to the user’s contact and photo information and to the
accelerometers and other hardware features of the device.

21.What is the Responder Chain?



When an event happens in a view, for example a touch event, the view will fire the event to
a chain of UIResponder objects associated with the UIView. The first UIResponder is the
UIView itself, if it does not handle the event then it continues up the chain to until
UIResponder handles the event. The chain will include UIViewControllers, parent UIViews
and their associated UIViewControllers, if none of those handle the event then the
UIWindow is asked if it can handle it and finally if that doesn't handle the event then the
UIApplicationDelegate is asked.

22-What is the difference between delegates, notifications, KVC, KVO and


Notification Center?

· Notifications:The concept of notification differs from delegation in that it allows a


message to be sent to more than one object. It is more like a broadcast rather than a
straight communication between two objects. It removes dependencies between the
sending and receiving object(s) by using a notification centre to manage the sending and
receiving of notifications. The sender does not need to know if there are any receivers
registered with the notification centre. There can be one, many or even no receivers of
the notification registered with the notification centre.Typical uses of notifications might
be to allow different objects with an application to be informed of an event such as a file
download completing or a user changing an application preference. The receiver of the
notification might then perform additional actions such as processing the downloaded file
or updating the display.
Key-Value-Coding (KVC) : accessing a property or value using a string.
Key-Value-Observing (KVO) : observe changes to a property or value, it is a many-to-
many relationship where one object broadcasts a message, and one or more other objects
listen to it and react. KVO does not rely on protocols. KVO is the first step and the
fundamental block of reactive programming (RxSwift, ReactiveCocoa, etc.)
Delegation: is a one-to-one relationship where one object implements a delegate protocol;
another sends messages to it, using methods defined by the protocol.Delegation is a design
pattern in which one object sends messages to another object specified as its delegate to ask
for input or to notify it that an event is occurring. Delegation is often used as an alternative
to class inheritance to extend the functionality of reusable objects. For example, before a
window changes size, it asks its delegate whether the new size is ok. The delegate replies to
the window, telling it that the suggested size is acceptable or suggesting a better size. (For
more details on window resizing, see thewindowWillResize:toSize: message.)Delegate

methods are typically grouped into a protocol. A protocol is basically just a list of methods.
The delegate
protocol specifies all the messages an object might send to its delegate. If a class conforms
to (or adopts) a protocol, it guarantees that it implements the required methods of a
protocol. (Protocols may also include optional methods).In this application, the application
object tells its delegate that the main startup routines have finished by sending it the
applicationDidFinishLaunching: message. The delegate is then able to perform additional
tasks if it wants.
Notification centre: it determines the observers of a particular notification and sends the
notification to them via a message. The methods invoked by the notification message must
conform to a certain single-parameter signature. The parameter of the method is the
notification object, which contains the notification name, the observed object, and a
dictionary containing any supplemental information.Posting a notification is a synchronous
procedure. The posting object doesn’t regain control until the notification centre has
broadcast the notification to all observers. For asynchronous behaviour, you can put the
notification in a notification queue; control returns immediately to the posting object and
the notification centre broadcasts the notification when it reaches the top of the
queue.Regular notifications that is, those broadcast by the notification centre—are
intraprocess only. If you want to broadcast notifications to other processes, you can use the
distributed notification centre and its related API.Notification Center is an observer pattern,
The NSNotificationCenter singleton allows us to broadcast information using an object
called NSNotification.
The biggest difference between KVO and Notification Center is that KVO tracks specific
changes to an object, while Notification Center is used to track generic events.

23-What is posing in iOS?


Objective-C permits a class to entirely replace another class within an application. The
replacing class is said to “pose as” the target class. All messages sent to the target
class are then instead received by the posing class. There are some restrictions on
which classes can pose:
• A class may only pose as one of its direct or indirect superclasses
• The posing class must not define any new instance variables which are absent from the
target class (though it may define or override methods). • No messages must have been
sent to the target class prior to the posing.similarly to categories, allows globally
augmenting existing classes.permits two features absent from categories:
• A posing class can call overridden methods through super, thus
incorporating the implementation of the target class.
• A posing class can override methods defined in categories.

24-What is atomic and nonatomic? Which one is safer? Which one is default?
Atomic and non-atomic refers to whether the setters/getters for a property will atomically
read and write values to the property. When the atomic keyword is used on a property, any
access to it will be “synchronised”. Therefore a call to the getter will be guaranteed to
return a valid value, however this does come with a small performance penalty. Hence in
some situations nonatomic is used to provide faster access to a property, but there is a
chance of a race condition causing the property to be nil under rare circumstances (when a
value is being set from another thread and the old value was released from memory but the

new value hasn’t yet been fully assigned to the location in memory for the property).You
can use this attribute to specify that accessor methods are not atomic. (There is no keyword
to denote atomic.)nonatomic.Specifies that accessors are nonatomic. By default, accessors
are atomic. Properties are atomic by default so that synthesised accessors provide robust
access to properties in a multithreaded environment—that is, the value returned from the
getter or set via the setter is always fully retrieved or set regardless of what other threads
are executing concurrently. If you specify strong, copy, or retain and do not specify
nonatomic, then in a reference-counted environment, a synthesised get accessor for an
object
If you specify nonatomic, a synthesised accessor for an object property simply returns the
value directly.

25-What are the tools required to develop iOS applications and where can you test
Apple iPhone apps if you don’t have the device?
• Mac/MacMini: It is necessary for us to get a Mac with the Intel-based processor
running on Mac OS. Not to worry, if we have our own PC, we can still develop iOS
apps through Mac Mini.
• Xcode: Xcode is the Apple IDE (Integrated Development Environment) that is used
for both iOS apps and MAC OS. It provides us a visual layout editor and a code
editor that can deal with the logic, user interface and response behind the scene.
• Swift Programming Language: In the code editor, the logic will be written in a
programming language that is invented by Apple, called Swift.
• Apple Developer Program: This program allows the developer to push our app live
on the App store so that the customers and downloaders all over the world can
download our app and use it.

26-How do you manage dependencies?


Dependency management is an important task in every iOS project. This question gauges
your understanding of the problem and its solution.A few years back, we didn’t have any
dependency managers on iOS and had to copy-paste and drag-and-drop third-party code
into our projects or to use Git sub-modules. Those approaches proved to be unmanageable
as our codebase and dependencies grew.
These days we have other dependency managers to choose from: CocoaPods, Carthage, and
Swift Package Manager.So far the most dominant and robust one is CocoaPods. I was built
in the spirit of the Ruby Bundler gem and is a Ruby gem itself. The way it works is you
install the gem, create Pod file in the root directory of your project, declare the pods
(libraries) you want to use, and run pod install. That’s it.
With Carthage, you create a dependencies declaration file called Cartfile but unlike Cocoa
pods you’d need to do Xcode project setup to make it work.Swift Package Manager is the
future of dependency management for any Swift project but it only supports libraries and
frameworks and cannot be used to generate iOS targets, although iOS targets can depend on
modules built by SPM.The Swift Package Manager will help to vastly improve the Swift
ecosystem, making Swift much easier to use and deploy on platforms without Xcode such
as Linux. The Swift Package Manager also addresses the problem of dependency hell that
can happen when using many interdependent libraries.The Swift Package Manager only
supports using the master branch. Swift Package Manager now supports packages with
Swift, C, C++ and Objective-C.

Every iOS developer should understand why copy-pasting third-party libraries into your
codebase leads to a maintenance nightmare when several libraries could depend on two
different versions of another library, causing mismatches and compile and runtime issues.
Many people starting with CocoaPods seem to think pod install is only used the first time
you setup a project using CocoaPods and pod update is used afterwards. But that's not the
case at all.

• Use pod install to install new pods in your project. Even if you already have a
Podfile and ran pod install before; so even if you are just adding/removing pods to a
project already using CocoaPods.
• Use pod update [PODNAME] only when you want to update pods to a newer
version.
This is to be used the first time you want to retrieve the pods for the project, but also every
time you edit your Podfile to add, update or remove a pod.
• Every time the pod install command is run — and downloads and install new pods
— it writes the version it has installed, for each pods, in the Podfile.lock file. This
file keeps track of the installed version of each pod and locks those versions.
• When you run pod install, it only resolves dependencies for pods that are not already
listed in the Podfile.lock.
◦ For pods listed in the Podfile.lock, it downloads the explicit version listed in
the Podfile.lock without trying to check if a newer version is available
◦ For pods not listed in the Podfile.lock yet, it searches for the version that
matches what is described in the Podfile (like in pod 'MyPod', ‘~>1.2')
When you run pod outdated, CocoaPods will list all pods which have newer versions than
the ones listed in the Podfile.lock (the versions currently installed for each pod). This means
that if you run pod update PODNAME on those pods, they will be updated — as long as the
new version still matches the restrictions like pod 'MyPod', '~>x.y' set in your Podfile.
pod repo update

pod repo update [NAME]

Updates the local clone of the spec-repo NAME. If NAME is omitted this will update all
spec-repos in /Users/dimitris/.cocoapods/repos.

27- Name 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. UIKit
framework provides event handling, drawing model, windows, views, and controls
specifically designed for a touch screen interface.UIKit classes should be used only from
an application’s main thread. Note: The derived classes of UIResponder and the classes
which manipulate application’s user interface should be used from application’s main
thread.The UIKit infrastructure takes care of delivering events to custom objects. As an app
developer, you have to override methods in the appropriate objects to process those events.

28-Name a few Git commands and explain their usage?


Below are some basic Git commands:
git rm [file] : deletes the file from your working directory and stages the deletion
git log : list the version history for the current branch

git show [commit] : shows the metadata and content changes of the specified commit
git tag [commitID] : used to give tags to the specified commit
git checkout [branch name] : used to switch from one branch to another
git checkout -b [branch name] : creates a new branch and also switches to it
The following steps will resolve conflict in Git-
1. Identify the files that have caused the conflict.
2. Make the necessary changes in the files so that conflict does not arise again.
3. Add these files by the command git add.
4. Finally to commit the changed file using the command git commit

29- Which API is used to write test scripts that help in exercising the
application’s user interface elements and Do you have TDD experience? How
do you unit and UI test on iOS?
UI Automation API is used to automate test procedures. Tests scripts are written in
JavaScript to the UI Automation API. This in turn simulates user interaction with the
application and returns log information to the host computer.Even though, historically, the
iOS community wasn’t big on TDD, it is now becoming more popular thanks to
improvements in tooling and influence from other communities, such as Ruby, that
embraced TDD a long time ago.TDD is a technique and a discipline where you write
failing tests first before you write production code that makes them pass. The tests drive
implementation and design of your production code, helping you write only the code
necessary to pass the tests implementation, no more, no less. The discipline could be
daunting at first and you don’t see payoff of that approach immediately, but if you stick to
it, it helps you move faster in the long run. It is especially effective at helping you with
refactoring and code changes because at any given time you have the safety net of your
tests to tell you if something broke or if everything is still working fine as you change
things.
Recently Apple made improvements to XCTest frameworks to make testing easier for us.
They also made a lot of improvements with UI testing in Xcode (XCUITest), so now we
have a nice programmatic interface to interact with our apps and query things we see on the
screen. Alternatively you could go with frameworks like KIF, iOSSnapshotTestCase,
EarlGrey.
In regards to unit testing, there are several options as well, but the two most popular ones
are XCTest and Quick and Nimble.
XCTest is a xUnit like testing framework built by Apple. This is what they recommend to
use, and it has the best integration with Xcode.
Quick is a Spec-like BDD framework that helps you describe your specs/tests in terms of
behaviour rather than “tests.” Fans of Spec like it a lot.
Nimble is a matcher library that can be used with XCTest or Quick to assert expectations in
your tests/specs.
More and more teams and companies embrace TDD, and it has become a vital part of the
iOS development process. If you don’t want to be left behind, get on board with it and learn
how to test-drive your code.
As testing becomes a more prominent and important practice in the iOS world, it’s
important to know what you’re doing as you write your tests. Your test code is as important

as your application code. This question gauges your understanding of testing terminology
for objects used to aid in unit-testing.
There are various ways different people call and categorise test objects but most commonly
test objects can be categorised in the following way: fakes, stubs, and mocks.
Fakes is the general umbrella term for any kind of mock, fake, stub, double, etc. On their
own, they typically have no implementation and only fulfil the interface API requirements
of the types they are substituting.
Stubs are fakes that do some meaningful work that’s necessary for the objects involved in a
test to operate, but not used for anything more than that. They can’t be used in place of real
production objects but can return stubbed values. They can’t be asserted on.
Mocks are fakes that can be asserted on. Mocks are used in place of other objects just like a
fake, but they themselves record some data such as the number of method calls or variables
passed for your test to assert on later.
Many developers make a mistake of calling any test object a mock, but there is a specific
distinct nomenclature for test objects that indicates the purpose for each one. As a senior
developer you’re not merely writing tests, you also should know how to maintain them as
well as your application codebase.

30-SSL Pinning in iOS and how would you securely store private user data offline on a
device? What other security best practices should be taken?
There are many popular options to perform SSL pining in iOS. These are- URLSession,
AlamoFire, AFNetworking, TrustKit. We can implement Certificate pinning as well as
public-key pining.
Why Do You Need SSL Certificate Pinning?
SSL pinning allows the application to only trust the valid or pre-defined certificate or Public
Key. The application developer uses SSL pinning technique as an additional security layer
for application traffic. As normally, the application trusts custom certificate and allows the
application to intercept the traffic.
Restricting the set of trusted certificates through pinning prevents attackers from analysing
the functionality of the app and the way it communicates with the server.
How SSL works?
• Client machine sends a connection request to server, server listens the request.
• Server gives response including public key and certificate.
• Client checks the certificate and sends a encrypted key to server.
• Server decrypt the key and sends encrypted data back to the client machine.
• Client receives and decrypt the encrypted data.
Types of SSL Pinning(What to Pin)?
• Pin the certificate: You can download the server’s certificate and put this in your app
bundle. At runtime, the app compares the server’s certificate to the one you’ve
embedded.
• Pin the public key: You can retrieve the certificate’s public key and include it in your
code as a string. At runtime, the app compares the certificate’s public key to the one
hard-coded hash string in your code.
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.

31-Codable Protocol with example


The new protocol introduced by Apple in Swift 4 provides built-in Encodable and
Decodable features. It makes JSON parsing easier. It can convert itself into and out of
an external representation.
Coding Keys with enum
We can modify our Codable key with custom string keys, but they should match your
JSON response keys. Otherwise, you’ll get an error message.
JSONEncoder and JSONDecoder classes which can easily convert an object to encoded
JSON representation.

struct employee:Codable
{
let name:String
let state:String
let zip:String
let area:String

private enum CodingKeys: String, CodingKey


{

case name
case state
case zip = "zip_code"
case area

let names=employee(name: "Apple", state: "Tg", zip: "500086", area: "Suncity")









let encoder=JSONEncoder()
if let jsondata=try? encoder.encode(names), let jsonString=String(data: jsondata,
encoding: .utf8)
{
print(jsonString)
}

32-Why is JIRA used?


Atlasssian JIRA is basically an issue and project tracking tool which allows us to track any
project related work by following a proper workflow.
Enlisted below are few reasons which determine the usage of JIRA:
• Able to track project progress from time to time.
• JIRA use-cases include project management, feature implementation, bug tracking,
etc.
• Work-flow can be easily customised as per our requirement.
• Along with issue tracking, history of the work done on issues, when, what and by
whom can also be tracked.
• JIRA is platform-independent and can run anywhere.
Workflow defines the series of steps or stages an issue/ bug goes through during its
lifecycle from creation to the closing of the issue.
The workflow here includes the creation of an issue, a series of actions performed to fix the
issue and the last step includes the closing or say completion of the issue after verification.
Refer the below diagram for better understanding:

33-Consider the following code:


let op1: Int = 1
let op2: UInt = 2
let op3: Double = 3.34
var result = op1 + op2 + op3
Where is the error and why? How can it be fixed?
Answer: Swift doesn’t define any implicit cast between data types, even if they are
conceptually almost identical (like UInt and Int).
To fix the error, rather than casting, an explicit conversion is required. In the sample code,
all expression operands must be converted to a common same type, which in this case is
Double:
var result = Double(op1) + Double(op2) + op3When an app is said to be in not
running state?

34.What is the use of SwiftLint in iOS?


SwiftLint is an open-source tool to enforce Swift style and convention. SwiftLint allows us
to enforce code style rules and stick to it during the development of iOS apps.





You can integrate SwiftLint into the development process and show you how to set up in
your local machine and Jenkins server to run the SwiftLint automatically.

35- What is Zendesk?


At its core, Zendesk is a customer support platform that lets you connect with customers on
any channel.
Whether your customers want to connect by phone, chat, email, social media, or any other
channel, Zendesk brings all your customer interactions to one easy to use platform to make
it easy to keep track of all your support requests, answer questions quickly, and monitor
customer service agent’s effectiveness.
Zendesk’s products are easy to set up and start using fast - most anything you’ll need to use
feature-wise will work right out of the box.
And their platform offers all the customer relationship management (CRM) tools you need
in an industry-leading cloud platform, so whether your a fast-growing startup or enterprise
looking to improve your current standards, Zendesk can scale to meet your needs.
If your company has been struggling to keep up with your customer support demands (say,
your first response times aren’t very good), you owe it to yourself and your company to
take a look at Zendesk
Ticketing System:
Zendesk’s ticketing system does that incredibly well - acting like a shared inbox for all of
your customer’s questions and concerns.
By bringing together requests from email, chat, Twitter, etc., they make it easy to keep track
of customer issues and conversations to more quickly answer questions and solve problems.

36-What is Jenkins?
Jenkins is a free open source Continuous Integration tool and automation server to monitor
continuous integration and delivery. It is written in Java.
It is known as an automated Continuous Delivery tool that helps to build and test the
software system with easy integration of changes to the system. Jenkins follows Groovy
Scripting.
Also, it enables developers to continuously check in their code and also analyse the post-
build actions. The automation testers can use to run their tests as soon as the new code is
added or code is modified.
Jenkins is used to continuously monitor the large code base in real-time. It enables
developers to find bugs in their code and fix them. Email notifications are made to the
developers regarding their check-ins as a post-build action.
Advantages of Jenkins are as follows:
• Build failures are cached during the integration stage.
• Notifies the developers about build report status using LDAP (Lightweight Directory
Access Protocol) mail server.
• Maven release project is automated with simple steps.
• Easy bug tracking.
• Automatic changes get updated in the build report with notification.
• Supports Continuous Integration in agile development and test-driven development.

37-Consider the following code:


var array1 = [1, 2, 3, 4, 5]


var array2 = array1


array2.append(6)
var len = array1.count
What’s the value of the len variable, and why?
Answer:The len variable is equal to 5, meaning that array1 has 5 elements, whereas array2
has 6 elements:
array1 = [1, 2, 3, 4, 5]
array2 = [1, 2, 3, 4, 5, 6]
When array1 is assigned to array2, a copy of array1 is actually created and assigned.
The reason is that swift arrays are value types (implemented as structs) and not reference
types (i.e. classes). When a value type is assigned to a variable, passed as argument to a
function or method, or otherwise moved around, a copy of it is actually created and
assigned or passed. Note that swift dictionaries are also value types, implemented as structs.
Value types in swift are:
• structs (incl. arrays and dictionaries)
• enumerations
• basic data types (boolean, integer, float, etc.)

38- What is the difference between Continuous Integration, Continuous Delivery,


and Continuous Deployment?
Continuous integration is the process of continuously checking-in the developer’s code into
a version control system and triggering the build to check and identify bugs in the written
code.
This is a very quick process and also gives them a chance to fix the bugs. Jenkins is one
such continuous integration tool.
In software development, multiple developers work on different software modules. While
performing integration testing all the modules are being integrated together. It is considered
as the development practice to integrate the code into the source repository
Whenever the programmer/developer makes any change to the current code, then it
automatically
gets integrated with the system running on the tester’s machine and makes the testing task
easy and speedy for the system testers.
Continuous Integration comprises of:
• Development and Compilation
• Database Integration
• Unit Testing
• Production Deployment
• Code Labeling
• Functional Testing
• Generating and Analysing Reports
The diagrammatic representation given below can elaborate on the differences between
Continuous Integration, Continuous Delivery, and Continuous Deployment more precisely.
Continuous Integration:
















(It involves keeping the latest copy of the source code at a commonly shared hub where all
the developers can check to fetch out the latest change in order to avoid conflict.)
Continuous Delivery:
Why Jenkins is being called as a Continuous Delivery Tool:
1. Developers work on their local environment for making changes in the source code
and push it into the code repository.
2. When a change is detected, Jenkins performs several tests and code standards to
check whether the changes are good to deploy or not.
3. Upon a successful build, it is being viewed by the developers.
4. Then the change is deployed manually on a staging environment where the client
can have a look at it.
5. When all the changes get approved by the developers, testers, and clients, the final
outcome is saved manually on the production server to be used by the end-users of
the product.
In this way, Jenkins follows a Continuous Delivery approach and is called the
Continuous Delivery Tool.

(Manual Deployment to Production. It does not involve every change to be deployed.)


Continuous Deployment:

(Automated Deployment to Production. Involves every change to be deployed


automatically.)

39-iOS 15 All the new features


Apple in June 2021 introduced the latest version of its iOS operating system, iOS 15, which
is set to be released in the fall. iOS 15 introduces new features for FaceTime calls, tools to
reduce distractions, a new notifications experience, added privacy features, complete
redesigns for Safari, Weather, and Maps, and more.
Notifications have been redesigned in iOS 15, adding contact photos for people and larger
icons for apps. To reduce distraction, a notification summary collects notifications together
for delivery at an appropriate time and arranges notifications by priority.
Focus is a new feature that can filter notifications and apps based on what a user wishes to
focus on at a certain time. When a user's Focus is blocking incoming notifications, their
status will be displayed to others in Messages. iOS will suggest a Focus for different
occasions, such as work hours or winding down for bed, using on-device intelligence, but
users can also create a custom Focus. When a Focus is set on one Apple device, it
automatically applies to other Apple devices.
Safari features a completely new design. Controls are now easier to reach with one hand
and give more focus to a webpage's content. There is a new, compact tab bar that floats at
the bottom of the screen so users can easily swipe between tabs. Tab Groups allow users to
save tabs and easily access them at any time across devices. There is also a customizable
start page and web extensions for the first time.
The Maps app now offers a new 3D view in cities with significantly enhanced details,
showing buildings, pedestrian crosswalks, bike lanes, and more. There is a new city-driving
experience with added road details and improved Transit features, such as pinned favorite
lines, notifications to disembark, and AR walking directions.
iOS 15 brings voice isolation and Spatial Audio to FaceTime calls so that voices sound as if
they are coming from where the person is located on the screen. FaceTime also supports
Portrait mode and offers a new grid view to see more faces at the same time. SharePlay is a
new feature that allows users to share media together in sync during a FaceTime call. Users
can also generate shareable links to a scheduled FaceTime call, which can also be opened
on Android and Windows devices.
The Weather app has been redesigned in iOS 15, showing more graphical displays of
weather data, full-screen maps, and dynamic layouts that change based on weather
conditions. Totally new animated backgrounds can now more accurately reflect the sun's
position and current precipitation, and there are notifications to highlight when rain or snow
starts and stops.
The Wallet app adds support for new key types in iOS 15, such as homes, offices, or hotel
rooms. Later this year, customers in participating U.S. states will be able to add a driver's
license or state ID to the Wallet app.
The Photos app features a major update to Memories with a new design and an interactive
interface. Memories now supports integration with Apple Music, using on-device
intelligence to offer song suggestions for personalized Memories.
Live Text is a new feature that uses on-device intelligence to recognize text in a photo that
users can search for, highlight, and copy. Spotlight can now search for photos by location,
people, scenes, objects, and text. Spotlight also offers web image search and richer results

for actors, musicians, TV shows, and movies.


Enhanced results for contacts show recent
conversations, shared photos, and location if it is
shared through Find My.
iOS 15 also introduces new privacy measures,
such as processing Siri requests directly on the iPhone,
which has the added benefit of better
responsiveness, Mail Privacy Protection to stop
senders knowing if an email has been opened and
detecting a recipient's IP address, and an App
Privacy Report view to show how often apps use the permissions they have been granted.
There are dozens of tweaks and changes for other apps, such as user-created tags, mentions,
and an Activity view in the Notes app, Trends, Walking Steadiness, and a new sharing tab in
the Health app, a systemwide Shared with You feature for highlighting content that has been
shared in Messages conversations, and a new For All of You row in the TV app to
recommend entertainment for the whole household.
iOS 15 is compatible with the iPhone 6s and later, which means it runs on all devices that
are able to run iOS 14, and will be released this fall.
40-Traits and Size Classes in iOS?
Traits define the features of the environment an app is likely to encounter when running on
an iOS device. Traits can be defined both by the hardware of the device and the way in
which the iOS environment has been configured by the user. Examples of hardware based

traits include hardware features such as the range of colours supported by the device display
(also referred to as the display gamut) and whether or not the device supports features such
as 3D Touch. The traits of a device that are dictated by user configuration include the
dynamic type size setting and whether the device is configured for left to right or right to
left text direction.
Arguably the most powerful trait category, however, relates specifically to the size and
orientation of the device screen. These trait values are referred to as size classes. Size
classes categorise the various screen areas that an application user interface is likely to
encounter during execution. Rather than represent specific screen dimensions and
orientations, size classes represent width (w) and height (h) in terms of being compact (C)
or regular (R).
Both the iPhone 7 and iPhone 7 Plus devices in portrait orientation, for example, are
represented by the compact width and regular height size class (wC hR). When the iPhone 7

is rotated to landscape orientation the device is considered to be of compact height and


compact width (wC hC). An iPhone 7 Plus in landscape orientation, on the other hand, is
categorised as being of compact height and regular width (wR hC).
In terms of size class categorisation, the iPad family of devices (including the iPad Pro) is
considered to be of regular height and regular width (wR hR) in both portrait and landscape
orientation. A range of different size class settings are used when apps are displayed on the
iPad.
Interface Builder in Xcode 8 allows different Auto Layout constraints to be configured for
different size class settings within a single storyboard file. In other words, size classes allow
a single user interface file to store multiple sets of layout data, with each data set targeting a
particular size class. At runtime, the application will use the layout data set for the size class
that matches the device and prevailing orientation on which it is executing, ensuring that
the user interface appears correctly.
By default, any layout settings configured within the Interface Builder environment will
apply to all size classes. Only when trait variations are specifically specified will the layout
configuration settings differ between size classes.
Customising a user interface for different size classes goes beyond the ability to configure
different Auto Layout constraints for different size classes. Size classes may also be used to
designate which views in a layout are visible within each class, and also which version of a
particular image is displayed to the user. A smaller image may be used when an app is
running on an iPhone SE, for example, or extra buttons might be made to appear to take
advantage of the larger iPad screen.
41-Who calls the main function of you app during the app launch cycle?
During app launching, the system creates a main thread for the app and calls the app’s main
function on that main thread. The Xcode project’s default main function hands over control
to the UIKit framework, which takes care of initialising the app before it is run.
iPhone applications by default have 3 things
1.main: entry point of application.
2.Appdelegate: perform basic application and functionality.
3.Window: provide uiinterface.

42-What is the use of controller object UIApplication?


Controller object UIApplication is used without subclassing to manage the
application event loop.
It coordinates other high-level app behaviours.
It works along with the app delegate object which contains app-level logic.
The app delegate object is created by UIApplicationMain function at app launch time.
The app delegate object’s main job is to handle state transitions within the app.
App delegate is declared as a subclass of UIResponder by Xcode project templates.

43-What is the difference between rebase and merge in Git?


In terms of the end result (which is what matters, usually), after merging the end result will
look like the commits on both branches were made chronologically "together", altering
between the branches. After rebasing, the end result will look like the branches were
'applied' separately, first one entire branch and then the other.
The most important takeaway is that if branch (a) has a list of commits:

{a1, a2, a3, a4, a5} and branch (b) has a list of commits {b1, b2, b3, b4, b5}, then after
merging them the result might be something like:
> a1, b1, a2, a3, b3, b4, b5, a5 (mixed together),
while after rebasing (b) over (a) the list will necessarily look like:
> a1, a2, a3, a4, a5, b1, b2, b3, b4, b5. (one branch after the other)
If (b) is your feature branch and (a) is your stable master, this is much preferable because
logically you want all of (b)'s commits after (or in git-speak, 'rebased on') the commit's on
(a)'s.
Both Git merge and Git rebase are used to combine the work of two branches together. Only
the techniques of combining is different.
Consider an example to understand the difference between these two techniques:
Let's say that you have two branches in your Git repo viz. master and feature, where the
feature branch is being used to develop something additional & master branch is your
production quality code branch or main branch.
After you are done developing the feature branch, you want to combine it with the master
branch.
If you Git merge it into master, it will combine the tasks of feature into master by creating a
single new commit at the tip of master.
On the other hand, if you Git rebase it, it will place the entire commit history of the feature
branch on the tip of master. It means that your entire feature branch will be reattached to the
tip of master and it will look like a linear sequence of commits.
However, there is a little rule to remember:
Combining tasks from public branch into local branch -- use git rebase
Combining tasks from local branch to public branch -- use git merge
Both Merge and Rebase have their pros and cons. Merge keeps the history of the repository
but can make it hard for someone to understand and follow what’s going on at a particular
stage when there are multiple merges. Rebase on the other hand ‘rewrites’ history (read -
creates new history) but makes the repo look cleaner and is much easier to look at.
What you want to use depends on your need. A lot of companies make merges mandatory
when adding stuff to master branch because they want to see the history of all changes. And
a few companies/Open source projects mandate rebasing as it keeps the flow simple and
easy to follow. Use the one that suits your workflow.

44- Which app specific objects store the app’s content?


Data model objects are app specific objects and store app’s content. Apps can also use
document objects to manage some or all of their data model objects.
Document objects are not required but are very useful in grouping data that belongs in
a single file or file package.
45-Explain static and dynamic library/framework in iOS?
First, some general definitions (specific to iOS):
Static library - a unit of code linked at compile time, which does not change.
However, iOS static libraries are not allowed to contain images/assets (only code). You can
get around this challenge by using a media bundle though.
Dynamic library - a unit of code and/or assets linked at runtime that may change.
However, only Apple is allowed to create dynamic libraries for iOS . You're not allowed to
create these, as this will get your app rejected.

Software Framework - a compiled set of code that accomplishes a task... hence, you can
actually have a static framework or a dynamic framework, which are typically just the
compiled versions of the above.
Hence on iOS, your only option is basically to use a static library or static framework (the
main difference being that a static framework is distributed as a compiled .a file most often,
whereas a static library may simply be included as a subproject - you can see all of the code
- which is compiled first and its resulting .a file used as a dependency by the project).
Now that we're clear(er) on these terms, setting up a static library and supporting media
bundle for iOS isn't too difficult, and there are many tutorials on how to do such. I
personally would recommend this one:
https://github.com/jverkoey/iOS-Framework
This is a pretty straight-forward guide and doesn't have the disadvantage of dealing with
"fake static libraries"... check it out for more info...
Once you've created your static library, it's as easy as including it as a submodule within Git
for use across different projects.
As of iOS 8, Apple now permits developers to create dynamic frameworks! (Note: your app
must have a minimum target of iOS 8 to include a dynamic framework... back porting isn't
allowed.)
This has been added as a new project template. In Xcode 6.1, this can be found at:
New Project -> iOS -> Framework & Library -> Cocoa Touch Framework

46- Common reasons for app rejection from App store review process?
• Broken Links:
There are a couple of needed links as a part of the App Store application method. For
example, your app must have a link to your privacy policy. You’ve additionally ought to
have a link to app support in order that users will contact you. If these links don’t go
anyplace, your app is rejected. Make sure these pages square measure in operating order
before submission.
• Bugs throughout the review method
Obviously, you wouldn’t need an automobile you were pondering shopping for to interrupt
down on the check drive. That’s an excellent thanks to making sure that the automobile isn’t
going get oversubscribed. By that very same token, a bug that rears its ugly head
throughout the review method can place your app on the main road to rejection. Each app
goes to possess some problems once it’s initial free, however, try and catch as several as
available throughput testing to avoid rejections and delays.
• Crashes throughout the review method
Moment dismissal anticipates your application on the off chance that it crashes all through
the review technique. Obviously, the App Store is trying to find apps that truly work. If they
don’t, they’re obtaining thrown the “no” pile.
• Long loading times
Your app has precisely fifteen seconds to load, or Apple goes to reject it. you'll reduce your
app load time by ensuring any pictures used square measure the adequate measure and
prioritising any bugs that reason the application to crash after loading. For a lot of insight in
decreasing load times, examine this text on important. measure and prioritising any bugs
that reason the application to crash after loading.
• Poor interface





Apps on the app store should supply worth and value to finish users. Apple is explicit
regarding the top quality of its applications. Look to satisfy the high-level style demand of
Apple, just as content size, content configuration, differentiate, arrangement, goals,
mutilation, hit controls, association, and so forth. Cohesive user expertise is essential to
obtain through the App Store.
• Apps that square measure demos or in beta
Demos aren’t happy with the Apple App Store. Words like “demo,” “test” and “beta” square
measure reaching to get flagged for rejection as a result of the App Store needs final
versions of apps. This is often simply inevitable and best observe anyway. You don’t wish
users are downloading associate imperfect version of your app.
• Mistreatment non-public API
Apple is that the sole guy on the block which will use a private API. ALL Apple apps have
to be compelled to use a public API so as to create it through the approval method. The
rationale is that Apple needs to make sure that public arthropod genus square measure in
use is to shield user knowledge from being abused.
• Inappropriate ad identifiers
Ads square measure a part of the method of building a lot of apps, however, if you utilise
IDFA (the iOS advertising identifier) on something that isn’t an advertisement, then you’re
reaching to get rejected right away.
• Unrelated keywords
Keywords square measure; however, users notice your app. However, mistreatment
keywords that square measure incorrect or square measure unrelated to the particular
mobile application square measure cause for fast rejection from Apple. It’s not legal to use
proprietary words, or titles that square measure deceptive. Apps got to gift themselves
honestly so as to create it through the app store approval method.
• Inappropriate content
Gambling and creative activity don't seem to be allowed within the App Store.
• Combination content
Content in mobile apps is supposed to be distinctive. Apps that square measure merely
aggregates of content which will be found elsewhere square measure the net goes to induce
kicked out by Apple. What goes informed any Apple application should be content that’s
usable and original for finish users. Plagiarism and aggregation can get your app showed
within the blink of a watch.
• Offensive language
Apple is supposed to be a secure area for folks of all non-secular faiths, ages, orientations,
etc. It’s ought to all be clean and on top of the board. Something that's meant to arouse
anger or to elicit a violent reaction can get thrown out right away.
• No privacy policy
It’s a tough and quick demand that each Apple app has a privacy policy in situ so as to
induce approval.
• Sharing personal user knowledge
Any app that shares personal user knowledge, from names to photos to contact info, are
rejected. Privacy could be a massive deal to Apple, and they’ve created a large quantity of
trust with users so as to spice up their whole and create the foremost out of their client
loyalty. Incursive privacy is simply not allowed.
• mistreatment Apple Pay while not the privacy policy










Another privacy policy issue is mistreatment Apple Pay while not the privacy policy for it.
That features any of the weather of stigmatisation or the interface generally.
• Missing information
A major demand for apps within the Apple Store is that they need information. Meaning as
well as screenshots, descriptions, etc. If the information isn’t there, then the app goes to
induce rejected.

47- Which is the super class of all view controller objects?


UIViewController class. The functionality for loading views, presenting them, rotating
them in response to device rotations, and several other standard system behaviours are
provided by UIViewController class. NSobject is the base class for all the classes and
default constructor syntax is - (id) init.
View controller objects takes care of the presentation of app’s content on the screen. A view
controller is used to manage a single view along with the collection of subviews. It makes
its views visible by installing them in the app’s window.
We use the super keyword to call the parent class initialiser after setting the child class
stored property.
48-What is the purpose of UIWindow and View object?
The presentation of one or more views on a screen is coordinated by UIWindow object.
To change the content of your app, you use a view controller to change the views
displayed in the corresponding window. Remember, window itself is never
replaced.
The presentation of one or more views on a screen is coordinated by UIWindow object.
To change the content of your app, you use a view controller to change the views
displayed in the corresponding window. Remember, window itself is never replaced.
Views along with controls are used to provide visual representation of the app content.
View is an object that draws content in a designated rectangular area and it responds to
events within that area.
49-How to call Objective-C code from Swift.
Follow the following steps:
Step 1: Add Objective-C Implementation --.m: First of all, add a .m file to the class and
then name it CustomObject.m.
Step 2: Add Bridging Header: At the time of adding your .m file, you receive a prompt
with three options of YES, NO and cancel. You need to select YES
Step 3: Add Objective-C Header --.h: After that Add one more .h file and name it
CustomObject.h.
Step 4: Build your Objective-C Class
In CustomObject.h
#import <Foundation/Foundation.h>
@interface CustomObject : NSObject
@property (strong, nonatomic) id someProperty;
- (void) someMethod;
@end
In CustomObject.m
#import "CustomObject.h"

@implementation CustomObject
- (void) someMethod {
NSLog(@"SomeMethod Ran");
}
@end
Step 5: The next step is to add Class to Bridging-Header
In YourProject-Bridging-Header.h
#import "CustomObject.h"
Step 6: At last, use your Object
In SomeSwiftFile.swift:
var instanceOfCustomObject: CustomObject = CustomObject()
instanceOfCustomObject.someProperty = "Hello World"
println(instanceOfCustomObject.someProperty)
instanceOfCustomObject.someMethod()
In the bridging header, there is no need to import explicitly.

50-Apart from incorporating views and controls, what else an app can
incorporate?
Apart from incorporating views and controls, an app can also incorporate Core Animation
layers into its view and control hierarchies.Layer objects are data objects which represent
visual content. Layer objects are used by views to render their content. Custom layer
objects can also be added to the interface to implement complex animations and other
types of sophisticated visual effects.

51-Difference between Unlocking and jailbroking in iPhone Explain its?


It lets you do everything from customising the look of your iPhone to installing third-party
applications(such as titles that are not authorised and available in the App Store) and
customised ringtones on it. Depending on how far you're willing to go, you can do
even more than that: Jailbreaking even lets you to unlock your phone so you can use
it with a carrier other than the one from which you purchased it.Once you do it,
you're on your own. You may have voided your warranty, so you can't rely on AT&T,
Verizon, or Apple to fix any problems you encounter. All of the applications that
jailbreak your phone are unauthorised and could damage or completely disable your
iPhone. Your slick smartphone could end up as nothing more than a very expensive
paperweight.

52-Define property, synthesised and instance variable?


Property/Instance:A property is a more abstract concept. An instance variable is literally
just a storage slot, like a slot in a struct. Normally other objects are never supposed to
access them directly. Usually a property will return or set an instance variable, but it could
use data from several or none at all.It is used to access instance variables outside of
class.After declaring property we will have to tell compiler instantly by using synthesise
directive. This tells the compiler to generate setter and getter methods.
Synthesised: Objective-c provides a mechanism that automates the creation of
accessor methods that are called synthesised accessor methods that are implemented
through use of the @property and @synthesized.

53-How and when to serialise, parse and map data on iOS?


Data serialisation is a common task when building iOS applications. Interviewers ask this
question to see if you recognise where it’s suitable and know of the tasks needed when
working with data, whether it’s networking or storage data.
There are two most common scenarios where you’d need to serialise and map data in iOS
applications: receiving or sending data in the networking layer (such as JSON or XML or
something else), and persisting or retrieving models in the storage layer (NSData,
NSManagedObject).
Every time you receive JSON or XML or any other response type of response from a
backend API, you most likely get it in a JSON or binary or other “inconvenient” format.
The first thing you need to do to work with the data you’ve received is to serialise it in
something your app understands. At the most simplest and basic level that would be a
dictionary or an array of objects containing other dictionaries, arrays, and primitives from
that response. NSJSONSerialization takes care of that. The next step is to map that data into
domain models of your application. Those would be the model objects or structs for the rest
of your application to use. You can either do it manually or use Codable protocol provided
by Apple or use a library such as Mantle or SwiftyJSON. The flow of data and serialisation/
mapping is: binary data -> json -> NSDictionary/NSArray -> your domain model objects.
Similarly, in the storage layer, you will need to serialise and map your data to and from
your custom domain model objects to the format your storage understands. The “mapping”
chain for reading data: db -> raw data format -> custom domain models; and for writing:
custom domain models -> raw data format -> db. You’d use the NSManagedObject or
NSCoding or Codable protocol here to achieve that.
The main red flag here is not being aware that these data manipulations need to happen
when working with the networking and storage layers of your iOS applications. Things do
not happen “automagically”, nor is working with raw NSDictionaries appropriate and
maintainable.
(a)Dom is “documents based parser”. b)SAX is an event driven parser and we will use
“NSXML” Parser and below are the methods.
(1)did start element (2)did end element (3)found character.

54-Which are the protocols used in table view and What is the reuseIdentifier used
for?
Table view contain two delegate protocols
(1) Uitable view data source
(2).Uitable view delegate.
ui view table view data source three method namely (1)No of sections.
(2)No of rows in sections.
(3)Cell for row index path row.
In ui table view delegate contain (1)Did select row at index path row

The reuseIdentifier is used to indicate that a cell can be re-used in a UITableView. For
example when the cell looks the same, but has different content. The UITableView will
maintain an internal cache of UITableViewCell’s with the reuseIdentifier and allow them to
be re-used when dequeueReusableCellWithIdentifier: is called. By re-using table cell’s the
scroll performance of the tableview is better because new views do not need to be created.

55-What options do you have for implementing storage, database and persistence on
iOS?
Interviewers ask this question to grasp your understanding of what tools and ways you have
available to store and persist data on iOS.
Generally there are the following ways to store data in order from simple to complex:
In-memory: arrays, dictionaries, sets, and other data structures are perfectly fine for storing
data intermediately or if it doesn’t have to be persisted.
NuserDefaults: If user removed the app from device the saved UserName and Password
also removed.
Keychain: If user removed the app from device the saved UserName and Password still is
there
Plist: Property lists organise data into named values and lists of values using several object
types. These types give you the means to produce data that is meaningfully structured,
transportable, storable, and accessible, but still as efficient as possible. Property lists are
frequently used by applications running on both Mac OS X and iOS. The property-list
programming interfaces for Cocoa and Core Foundation allow you to convert hierarchically
structured combinations of these basic types of objects to and from standard XML. You can
save the XML data to disk and later use it to reconstruct the original objects.The user
defaults system, which you programmatically access through the NSUserDefaults class,
uses property lists to store objects representing user preferences. This limitation would
seem to exclude many kinds of objects, such as NSColor and NSFont objects, from the user
default system. But if objects conform to the NSCoding protocol they can be archived to
NSData objects, which are property list–compatible objects.
File/disk storage: is a way of writing data (serialised or not) to/from a disk using
NSFileManager.
Core Data/Realm: are frameworks that simplify work with databases.
SQLite: is a relational database and is good when you need to implement complex
querying mechanics and Core Data or Realm won’t cut it.
Below is the sqlite methods:
sqlite3_open, sqlite3_prepare_v2, sqlite3_step, sqlite3_finalize, sqlite3_close, sqlite3_ok,
sqlite3_row
You should know different ways store data on iOS and their advantages or disadvantages.
Don’t limit yourself to only one solution that you’re used to (like Core Data, for example).
Know when one is preferable over the other.

56-What is the major purposes of Frameworks and tell four frameworks used in
iPhone?
Frameworks have three major purposes:
Code encapsulation
Code modularity
Code reuse
You can share your framework with your other apps, team members, or the iOS community.
When combined with Swift’s access control, frameworks help define strong, testable
interfaces between code modules.
(1)Ui kit framework
(2)Map kit framework






(3)ADI kit framework


(4)Core data framework (5)core foundation framework

57-What is the instance method, class method and accessor methods?


Instance methods: are essentially code routines that perform tasks so instances of classes
we create object to access, methods to get and set the instance variables and to display the
current values of these variables.
Class methods: work at the class level and are common to all instance of a class these
methods are specific to the class overall as opposed to working on different instance data
encapsulated in each class instance.
Accessor methods: Dot notation features introduced into version 2.0 of objective-c.
Dot notation involves accessing an instance variable by specifying a class “instance”
followed by a “dot” followed in turn by the name of instance variable or property to be
accessed.
Accessor methods are methods belonging to a class that allow to get and set the values of
instance valuables contained within the class.

58-Difference between shallow copy and deep copy?


Shallow copy is also known as address copy. In this process you only copy address
not actual data while in deep copy you copy data.
Suppose there are two objects A and B. A is pointing to a different array while B is pointing
to different array. Now what I will do is following to do shallow copy.
Char *A = {‘a’,’b’,’c’};
Char *B = {‘x’,’y’,’z’};
B. = A;
Now B is pointing is at same location where A pointer is pointing.Both A and B in this case
sharing same data. if change is made both will get altered value of data.Advantage is that
coping process is very fast and is independent of size of array.
while in deep copy data is also copied. This process is slow but Both A and B have their
own copies and changes made to any copy, other will copy will not be affected.
59-How to optimise scrolling performance of dynamically sized table or collection
views?Can we use two tableview controllers on one view controller?
One of the important questions on interviews along with UITableView questions is about
scrolling performance.
Scrolling performance is a big issue with UITableViews and quite often can be very hard to
get right. The main difficulty is cell height calculation. When the user scrolls, every next
cell needs to calculate its content and then height before it can be displayed. If you do
manual Frame view layouts then it is more performant but the challenge is to get the height
and size calculations just right. If you use AutoLayout then the challenge is to set all the
constraints right. But even AutoLayout itself could take some time to compute cell heights,
and your scrolling performance will suffer.
Potential solutions for scrolling performance issues could be:
• calculate cell height yourself
• keep a prototype cell you fill with content and use it to calculate cell height

Alternatively, you could take a completely radical approach, which is to use different
technology like ASDK (Texture). ASDK (Texture) is made specifically for list views with
dynamic content size and is optimised to calculate cell heights in a background thread,
which makes it super performant.Yes, we can use two tableviews on the same view
controllers and you can differentiate between two by assigning them tags...or you can also
check them by comparing their memory addresses.Yes. We can conditionally bind
tableviews with two different data sources.

60-Swap the two variable values without taking third variable?

For Int :
var x = 5
var y = 7

x=x+y
y=x-y
x=x-y
print(x)
print(y)

For Other Types :


var a = "a"
var b = "b"
(b, a) = (a, b)

61-Determine the value of “x” in the Swift code below. Explain your answer.
var a1 = [1, 2, 3, 4, 5]
var a2 = a1
a2.append(6)
var x = a1.count
In Swift, arrays are implemented as structs, making them value types rather than reference
types (i.e., classes). When a value type is assigned to a variable as an argument to a function
or method, a copy is created and assigned or passed. As a result, the value of “x” or the
count of array “a1” remains equal to 5 while the count of array “a2” is equal to 6,
appending the integer “6” onto a copy of the array “a1.” The arrays appear in the box
below.
a1 = [1, 2, 3, 4, 5]
a2 = [1, 2, 3, 4, 5, 6]

62- InApp purchase product type


1. Consumable products must be purchased each time the user needs that item. For
example, one-time services are commonly implemented as consumable products.
2. Non-consumable products are purchased only once by a particular user. Once a non-
consumable product is purchased, it is provided to all devices associated with that
user’s iTunes account. Store Kit provides built-in support to restore non-consumable
products on multiple devices.

3. Auto-renewable subscriptions are delivered to all of a user’s devices in the same


way as non-consumable products. However, auto-renewable subscriptions differ in
other ways. When you create an auto-renewable subscription in iTunes Connect,
you choose the duration of the subscription. The App Store automatically renews
the subscription each time its term expires. If the user chooses to not allow the
subscription to be renewed, the user’s access to the subscription is revoked after
the subscription expires. Your application is responsible for validating whether
a subscription is currently active and can also receive an updated receipt for the most recent
transaction.
4. Free subscriptions are a way for you to put free subscription content in
Newsstand. Once a user signs up for a free subscription, the content is available on all
devices associated with the user’s Apple ID. Free subscriptions do not expire and can only
be offered in Newsstand-enabled apps
Consumable products: can be purchased more than once and used items would have to re-
purchase.
Non-consumable products: user would be able to restore this functionality in the
future, should they need to reinstall the app for any reason. We can also add
subscriptions to our app.
Non-Renewing Subscription: Used for a certain amount of time and certain content.
Auto-Renewing Subscription: Used for recurring monthly subscriptions.
libssl_iOS and libcrypto_iOS
These files are going to help us with on device verification of our receipt verification files
with In-App purchases.

63-What is the navigation controller and split view controller?


Navigation controller contains the stack of controllers every navigation controller
must be having root view controller by default these controllers contain 2 method
(a) push view (b) pop view
By default navigation controller contain “table view”.
split view controller is used for iPad application and it contain proper controllers by
default
split view controller contain root view controller and detail view controller.

64-The following code snippet results in a compile time error and explain mutating
function:
struct IntStack {
var items = [Int]()
func add(x: Int) {
items.append(x) // Compile time error here.
}
}
Explain why a compile time error occurs. How can you fix it?
Answer: Structures are value types. By default, the properties of a value type cannot be
modified from within its instance methods.


















However, you can optionally allow such modification to occur by declaring the instance
methods as ‘mutating’; e.g.:
struct IntStack {
var items = [Int]()
mutating func add(x: Int) {
items.append(x) // All good!
}
}

65-What is mean by App Thinning.

There are three main aspects of App Thinning: App Slicing, Bitcode, and On Demand
Resources.

App Slicing:
“Slicing is the process of creating and delivering variants of the app bundle for different
target devices.
A variant contains only the executable architecture and resources that are needed for the
target device.” In other words, App Slicing delivers only relevant assets to each device
(depending on screen resolution, architecture, etc.) In fact, app slicing handles the majority
of the app thinning process.But must use Xcode 7 as it contains the iOS 9 SDK with
support for app thinning.
On Demand Resources are files that can be downloaded after the app’s first installation.
For example, specific levels of a game (and these levels’ associated content) could be
downloaded only when the player has unlocked them. Further, earlier levels that the player
has not engaged with after a certain set time can be removed to save storage on the device.

Bitcode:
Bitcode makes apps as fast and efficient as possible on whatever device they’re running.
Bitcode automatically compiles the app for the most recent compiler and optimises it for
specific architectures (i.e. arm64 for 64 bit processors such as the iPhone 6s and iPad Air
2).

App Thinning in Your Own Projects:


Asset catalogs are the default in most apps at this point.
First, run the app on the simulator or a device.You’ll notice it is roughly 17.0 MB in size
(this size may vary slightly when uploaded to iTunes Connect).
Install this build. you notice that the app is now a mere 5.4 MB. That’s App Thinning at its
prime!












66-What is Cocoa and application Kit/App kit.


Cocoa: is an application environment for both the Mac OS X operating system and iOS. It
consists of a suite of object-oriented software libraries, a runtime system, and an integrated
development environment. Carbon is an alternative environment in Mac OS X, but it is a
compatibility framework with procedural programmatic interfaces intended to support
existing Mac OS X code bases.
Appkit (Application Kit) Foundation

Application Kit: is a framework containing all the objects you need to implement your
graphical, event-driven user interface: windows, panels, buttons, menus, scrollers, and text
fields. The Application Kit handles all the details for you as it efficiently draws on the
screen, communicates with hardware devices and screen buffers, clears areas off the
screen before drawing, and clips views.
You also have the choice at which level you use the Application Kit:
· Use Interface Builder to create connections from user interface objects to your application
objects.
· Control the user interface programmatically, which requires more familiarity with
AppKit classes and protocols.
· Implement your own objects by subclassing NSView or other classes.
·
67-Selectors, Dynamic and Static Typing.
Selector: has two meanings. It can be used to refer simply to the name of a method when
it’s used in a source-code message to an object. It also, though, refers to the unique
identifier that replaces the name when the source code is compiled. Compiled selectors are
of type SEL. All methods with the same name have the same selector. You can use a
selector to invoke a method on an object this provides the basis for the implementation of
the target-action design pattern in Cocoa.
Static typed: languages are those in which type checking is done at compile-time.
Dynamic typed: languages are those in which type checking is done at run-
time.Objective-C is a dynamically-typed language, meaning that you don’t have to tell
the compiler what type of object you’re working with at compile time. Declaring a
type for a variable is merely a promise which can be broken at runtime if the code
leaves room for such a thing. You can declare your variables as type id, which is
suitable for any Objective-C object.
68-What are design patterns besides common Cocoa patterns that you know?
This is an advanced question that an interviewer will ask when you interview for a senior or
architect position. The expectation is that you know more practical design patterns used in
iOS apps beyond the basic ones covered in the earlier question. Be ready to recall a bunch
of Gang of Four patterns and other similar patterns.
Design patterns are a huge topic on their own (they are covered better in my book), so here
I’ll only summarise those I see commonly in iOS code bases.
Besides commonly used MVC, Singleton, Delegate, and Observer patterns, there are many
others that are perfectly applicable in iOS applications: Factory Method, Adapter,Decorator,
Command, and Template.

Factory Method is used to replace class constructors, too abstract and hide objects
initialisation so that the type can be determined at runtime, and to hide and contain switch/if
statements that determine the type of object to be instantiated.
Adapter is a design pattern that helps you, as the name suggests, adapt the interface of one
object to the interface of another. This pattern is often used when you try to adapt third-
party code that you can’t change to your code, or when you need to use something that has
an inconvenient or incompatible API.
Decorator is a wrapper around another class that enhances its capabilities. It wraps around
something that you want to decorate, implements its interface, and delegates messages sent
to it to the underlying object or enhances them or provides its own implementation.
Command is a design pattern where you’d implement an object that represents an
operation that you would like to execute. That operation can have its own state and logic to
perform the task it does. The main advantages of this design pattern are that you can hide
internal implementation of the operation from the users, you can add undo/redo capabilities
to it, and you can execute operations at a later point in time (or not at all) instead of right
away where the operation was created.
Template is a design pattern where the main concept is to have a base class that outlines the
algorithm of what needs to be done. The base class has several abstract methods that are
required to be implemented by its concrete subclasses. These methods are called hook
methods. Users of the Template Method classes only interact using the base class that
implements the algorithm steps; concrete implementations of those steps are supplied by
subclasses.
Sticking only to MVC, Singleton, Delegate, and Observer patterns is fine when you’re just
starting with the iOS platform, but for advanced things you need to reach deeper into more
abstract and high-level stuff like Gang of Four OOP Design Patterns. They are very useful
and make your codebase more flexible and maintainable.
69-Class Introspection
· Determine whether an objective-C object is an instance of a class
[obj isMemberOfClass:someClass];
· Determine whether an objective-C object is an instance of a class or its
descendants
[obj isKindOfClass:someClass];
· The version of a class
[MyString version]
· Find the class of an Objective-C object
· Verify 2 Objective-C objects are of the same class
[obj1 class] == [obj2 class]
·
70- Proxy
As long as there aren’t any extra instance variables, any subclass can proxy itself as its
superclass with a single call. Each class that inherits from the superclass, no matter where it
comes from, will now inherit from the proxied subclass. Calling a method in the superclass
will actually call the method in the subclass. For libraries where many objects inherit from
a base class, proxying the superclass can be all that is needed.
71- Why category is better than inheritance?

Objective c subclass can derived from a single parent class.It is called “single
inheritance”
If category is used, you can use same class, no need to remember a new class-name.
Category created on a base class is available on sub classes.

72- Formal vs informal protocol and Optional vs required.


A protocol is a language feature in objective C which provides multiple inheritance in a
single inheritance language. Objective C supports two types of protocols:
• Ad hoc protocols called informal protocol
• Compiler protocols called formal protocols
Formal Protocols: allow us to define the interface for a set of methods, but
implementation is not done. This will useful when you are using DistributedObjects,
because they allow you to define a protocol for communication between objects, so that
the DO system doesn’t have to constantly check whether or not a certain method is
implemented by the distant object.
In addition to formal protocols, you can also define an informal protocol by grouping
the methods.
Informal protocols: are typically declared as categories of the NSObject class, because
that broadly associates the method names with any class that inherits from NSObject.
Because all classes inherit from the root class, the methods aren’t restricted to any part of
the inheritance hierarchy. (It is also possible to declare an informal protocol as a category of
another class to limit it to a certain branch of the inheritance hierarchy, but there is little
reason to do so.) When used to declare a protocol, a category interface doesn’t have a
corresponding implementation. Instead, classes that implement the protocol declare the
methods again in their own interface files and define them along with other methods in
their implementation files.
An informal protocol bends the rules of category declarations to list a group of methods but
not associate them with any particular class or implementation. Being informal, protocols
declared in categories don’t receive much language support. There’s no type checking at
compile time nor a check at runtime to see whether an object conforms to the protocol. To
get these benefits, you must use a formal protocol. An informal protocol may be useful
when all the methods are optional, such as for a delegate, but (in Mac OS X v10.5 and later)
it is typically better to use a formal protocol with optional methods.
Optional/required: Protocol methods can be marked as optional using the @optional
keyword. Corresponding to the @optional modal keyword, there is a @required keyword to
formally denote the semantics of the default behaviour. You can use @optional and
@required to partition your protocol into sections as you see fit. If you do not specify any
keyword, the default is @required.

73-Which is faster: for a search an NSArray or an NSSet?


When the order of the items in the collection is not important, NSSet offers better
performance for finding items in the collection; the reason is that the NSSet uses hash
values to find items (like a dictionary), while an array has to iterate over its entire contents
to find a particular object.
74-alloc vs new vs Copy vs assign vs retain vs mutableCopy

alloc: creates a new memory location but doesn’t initialises it


new: creates a new memory location and initialises it
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, copy always creates an immutable copy.
mutableCopy: always creates a mutable copy.
If you alloc, retain, or copy/mutable copy it, it’s your job to release it. Otherwise it isn’t.
Assign: creates a reference from one object to another without increasing the source’s
retain count.Assign is for primitive values like BOOL, NSInteger or double. For objects use
retain or copy, depending on if you want to keep a reference to the original object or make a
copy of it.
This can cause problems since Objective-C objects use reference counting, and therefore
by not retaining the object, there is a chance that the string could be deallocated whilst you
are still using it.

75-What is Sandbox in iPhone ?


The sandbox is a term used to describe the limited file system available to each
application.Each app only has access to a few directories:read-only access to the
application bundle (a special type of directory) read-write access to a documents
directory and a temp directory. Apps can't read or write to any other directories,
either system directories or those belonging to other apps.Another way to think
about it by pulling an analogy in is to think of an actual sandbox at a park.If kid A is
playing in sandbox A, then anything in that space is available to them. Kid B from
sandbox B should not be able to interfere in any way with sandbox A. Each is its
own small environment.In the real world the borders are physical, in the iPhone, you
have somewhat of a physical partition between applications as they each get their
own folder structure, but it's up to the OS to maintain the logical separation. Get
elevated privileges on the device and then the borders start to go away.

76-Coredata
To demonstrate this, we’re going to build two Core Data entities: one to track candy bars,
and one to track countries where those bars come from.
Relationships come in four forms:
• A one to one relationship means that one object in an entity links to exactly one
object in another entity. In our example, this would mean that each type of candy has
one country of origin, and each country could make only one type of candy.
• A one to many relationship means that one object in an entity links to many objects
in another entity. In our example, this would mean that one type of candy could have
been introduced simultaneously in many countries, but that each country still could
only make one type of candy.
• A many to one relationship means that many objects in an entity link to one object in
another entity. In our example, this would mean that each type of candy has one
country of origin, and that each country can make many types of candy.

• A many to many relationship means that many objects in an entity link to many
objects in another entity. In our example, this would mean that one type of candy had
been introduced simultaneously in many countries, and each country can make many
types of candy.
NSManagedObject represents a single object stored in Core Data; you must use it to create,
edit, save and delete from your Core Data persistent store. As you’ll see shortly,
NSManagedObject is a shape-shifter. It can take the form of any entity in your Data Model,
appropriating whatever attributes and relationships you defined.
This is where Core Data kicks in! Here’s what the code does:
1 Before you can save or retrieve anything from your Core Data store, you first need to
get your hands on an NSManagedObjectContext. You can consider a managed object
context as an in-memory “scratchpad” for working with managed objects.
Think of saving a new managed object to Core Data as a two-step process: first, you
insert a new managed object into a managed object context; then, after you’re happy
with your shiny new managed object, you “commit” the changes in your managed
object context to save it to disk.
Xcode has already generated a managed object context as part of the new project’s
template. Remember, this only happens if you check the Use Core Data checkbox at
the beginning. This default managed object context lives as a property of the
NSPersistentContainer in the application delegate. To access it, you first get a
reference to the app delegate.
2 You create a new managed object and insert it into the managed object context. You
can do this in one step with NSManagedObject’s static method:
entity(forEntityName:in:).
You may be wondering what an NSEntityDescription is all about. Recall earlier,
NSManagedObject was called a shape-shifter class because it can represent any
entity. An entity description is the piece linking the entity definition from your Data
Model with an instance of NSManagedObject at runtime.
3 With an NSManagedObject in hand, you set the name attribute using key-value
coding. You must spell the KVC key (name in this case) exactly as it appears in your
Data Model, otherwise your app will crash at runtime.
4 You commit your changes to person and save to disk by calling save on the managed
object context. Note save can throw an error, which is why you call it using the try
keyword within a do-catch block. Finally, insert the new managed object into the
people array so it shows up when the table view reloads.

1 Before you can do anything with Core Data, you need a managed object context.
Fetching is no different! Like before, you pull up the application delegate and grab a
reference to its persistent container to get your hands on its
NSManagedObjectContext.
2 As the name suggests, NSFetchRequest is the class responsible for fetching from
Core Data. Fetch requests are both powerful and flexible. You can use fetch requests
to fetch a set of objects meeting the provided criteria (i.e. give me all employees
living in Wisconsin and have been with the company at least three years), individual
values (i.e. give me the longest name in the database) and more.
Fetch requests have several qualifiers used to refine the set of results returned. For
now, you should know NSEntityDescription is a required one of these qualifiers.















Setting a fetch request’s entity property, or alternatively initialising it with
init(entityName:), fetches all objects of a particular entity. This is what you do here
to fetch all Person entities. Also note NSFetchRequest is a generic type. This use of
generics specifies a fetch request’s expected return type, in this case
NSManagedObject.
3 You hand the fetch request over to the managed object context to do the heavy
lifting. fetch(_:) returns an array of managed objects meeting the criteria specified by
the fetch request.
When we talk about persistent data, people probably think of database. If you are familiar
with Oracle or MySQL, you know that relational database stores data in the form of table,
row and column, and it usually facilitates access through what-so-called SQL query.
However, don’t mix up Core Data with database. Though SQLite database is the default
persistent store for Core Data on iPhone, Core Data is not a relational database. It is
actually a framework that lets developers store (or retrieve) data in database in an object-
oriented way. With Core Data, you can easily map the objects in your apps to the table
records in the database without even knowing any SQL.
Managed Object Model – It describes the schema that you use in the app. If you have a
database background, think of this as the database schema. However, the schema is
represented by a collection of objects (also known as entities). In Xcode, the Managed
Object Model is defined in a file with the extension .xcdatamodeld. You can use the visual
editor to define the entities and their attributes, as well as, relationships.
Persistent Store Coordinator – SQLite is the default persistent store in iOS. However,
Core Data allows developers to setup multiple stores containing different entities. The
Persistent Store Coordinator is the party responsible to manage different persistent object
stores and save the objects to the stores. Forget about it you don’t understand what it is.
You’ll not interact with Persistent Store Coordinator directly when using Core Data.
Managed Object Context – Think of it as a “scratch pad” containing objects that interacts
with data in persistent store. Its job is to manage objects created and returned using Core
Data. Among the components in the Core Data Stack, the Managed Object Context is the
one you’ll work with for most of the time. In general, whenever you need to fetch and save
objects in persistent store, the context is the first component you’ll talk to.
NSSQLiteStoreType: This is the option you most commonly use as it just stores your
database in a SQLite database.
NSXMLStoreType: This will store your data in an XML file, which is slower, but you can
open the XML file and it will be human readable. This has the option of helping you debug
errors relating to storage of data. However, do note that this storage type is only available
for Mac OS X.
NSBinaryStoreType: This occupies the least amount of space and also produces the fastest
speed as it stores all data as a binary file, but the entire database binary need to be able to fit
into memory in order to work properly.
NSInMemoryStoreType: This stores all data in memory and provides the fastest access
speed. However, the size of your database to be saved cannot exceed…
Core Data supports four delete rules:
• No Action
• Nullify
• Cascade
• Deny


No Action Delete Rule:


If the delete rule of a relationship is set to No Action, nothing happens. Let me illustrate this
with an example. We have a category that contains several notes. If the category is deleted,
the notes are not notified of this event. The notes on the other end of the relationship
believe that they are still associated with the deleted category.
Nullify Delete Rule:
If the delete rule of a relationship is set to Nullify, the destination of the relationship is
nullified when the record is deleted.
For example, if a category has several notes and the category is deleted, the relationships
pointing from the notes to the category are nullified. This is the default delete rule and the
delete rule you will find yourself using most often.
Cascade Delete Rule:
The Cascade delete rule is useful if the data model includes one or more dependencies. Let
me give you an example. If a note should always have a category, the deletion of a category
should automatically delete the notes associated with that category. In other words, the
deletion of the category cascades or trickles down to the notes linked to the category. Even
though this may make sense on paper, the user probably won't like it when you
automatically delete its notes. The Deny delete rule is a better option in this scenario (see
below).
Remember the previous example in which the deletion of a category resulted in the deletion
of every note that belonged to that category. It may be better to apply the Deny delete rule.
Deny: is another powerful and useful pattern. It is the opposite of the Cascade delete rule.
Instead of cascading the deletion of a record, it prevents the deletion of the record.
For example, if a category is associated with several notes, the category can only be deleted
if it is no longer tied to any notes. This configuration prevents the scenario in which notes
are no longer associated with a category.
The below illustration can probably give you a better idea about the Core Data Stack:

Core Data Stack


77- Event Loop
In a Cocoa application, user activities result in events. These might be mouse clicks or
drags, typing on the keyboard, choosing a menu item, and so on. Other events can be

generated automatically, for example a timer firing periodically, or something coming in


over the network. For each event, Cocoa expects there to be an object or group of objects
ready to handle that event appropriately. The event loop is where such events are detected
and routed off to the appropriate place. Whenever Cocoa is not doing anything else, it is
sitting in the event loop waiting for an event to arrive. (In fact, Cocoa doesn’t poll for
events as suggested, but instead its main thread goes to sleep. When an event arrives, the
OS wakes up the thread and event processing resumes. This is much more efficient than
polling and allows other applications to run more smoothly).Each event is handled as an
individual thing, then the event loop gets the next event, and so on. If an event causes an
update to be required, this is checked at the end of the event and if needed, and window
refreshes are carried out.

78-What will be the output for below code.


var name1:String!
override func viewDidLoad() {
let obj=name1!.count
print(obj as Any)
super.viewDidLoad()
// Do any additional setup after loading the view.
}
App will crash because of accessing nil value

79-What is the difference Stack and Heap ?


Our code takes up some space in the iOS. The size of this is sometimes fixed and
sometimes it can change according to what the user will enter during the program. Basically
we have two different methods because of this difference: Stack and Heap
Stack is used and automatically removes itself from memory after work is finished. But in
Heap the user could do it by writing manual code for deleting from memory.
Stack;
Stack is easy to use.
It’s kept in RAM on the computer.
Created variables are automatically deleted when they exit the stack.
It is quite fast compared to Heap.
Constructed variables can be used without a pointer.
Heap;
Compared to Stack, it is quite slow.
It creates memory problems if not used correctly.
Variables are used with pointers.
It is created at runtime.

80-Collection
Swift uses a standard set of basic data types for different purposes such as Boolean values,
numbers, and strings.
• Int: int is used to store the integer value.
• Double and Float: Double and Float in swift are considered when while working
with the decimal numbers.









Bool: The bool type is used to store the Boolean value. In swift, it uses true and false

conditions.
• String: In String literals, the user defines the text that is enclosed by double quotes
in Swift.
• Arrays: Arrays are the collection of list items.
• Dictionaries: A dictionary is an unordered collection of items of a particular type
that is connected with a unique key.
• An array can hold only one type of data, whereas NSArray can hold different types
of data.
• An array is a value type, whereas NSArray is an immutable reference type.
There are three primary collection types that are available in swift for storing a collection of
values. They are dictionaries, sets, and arrays
1. Arrays: Arrays is an ordered collection of values, which is stored in the same type
of values in an ordered list.
2. Sets: Sets are an unordered collection of unique values, which are stored in a distinct
value of the same type in a collection without any defined ordering.
3. Dictionaries: Dictionaries are an unordered collection of Key and value pair
associations in an unordered manner.
In Cocoa and Cocoa Touch, a collection is a Foundation framework class used for storing
and managing groups of objects. Its primary role is to store objects in the form of either
an array, a dictionary, or a set.

81-What is Deep Linking, HealthKit, Neural networks with Core ML?


Deep linking: is a way to pass data to your application from any platform like, website or
any other application. By tapping once on link, you can pass necessary data to your
application.
HealthKit: is a framework on iOS. It stores health and fitness data in a central location. It
takes in data from multiple sources, which could be different devices. It allows users to
control access to their data and maintains privacy of user data. Data is synced between your
phone and your watch.
Neural networks: and deep learning currently provide the best solutions too many
problems in image recognition, speech recognition, and natural language processing.
Core ML is an iOS framework comes with iOS 11, helps to process models in your apps for
face detection. For more information follow this guideline https://developer.apple.com/
machine-learning/
82-.Can you spot the bug in the following code and suggest how to fix it:
@interface MyCustomController : UIViewController
@property (strong, nonatomic) UILabel *alert;
@end

@implementation MyCustomController
- (void)viewDidLoad {
CGRect frame = CGRectMake(100, 100, 100, 50);
self.alert = [[UILabel alloc] initWithFrame:frame];
self.alert.text = @"Please wait...";
[self.view addSubview:self.alert];

dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
sleep(10);
self.alert.text = @"Waiting over";
}
);
}

@end
All UI updates must be done on the main thread. In the code above the update to the alert
text may or may not happen on the main thread, since the global dispatch queue makes no
guarantees . Therefore the code should be modified to always run the UI update on the main
thread
dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
sleep(10);
dispatch_async(dispatch_get_main_queue(), ^{
self.alert.text = @"Waiting over";
});
});

83-What will be the output for below code.


var name:String?
override func viewDidLoad() {
let obj=name?.count
print(obj as Any)
super.viewDidLoad()
// Do any additional setup after loading the view.
}
Output is nil value

84-What is the use of ? , ??, ! , Downcasting, zip?


The question mark ? is used during the declaration of a property, as it tells the compiler that
this property is optional. The property may hold a value or not, in the latter case it's possible
to avoid runtime errors when accessing that property by using ?. This is useful in optional
chaining.
To provide a default value for a variable.
let missingName : String? = nil
let realName : String? = “John Doe"
let existentName : String = missingName ?? realName
Highly related to the previous keywords, the ! is used to tell the compiler that I know
definitely, this variable/constant contains a value and please use it (i.e. please unwrap the
optional). From question 1, the block that executes the if condition is true and calls a forced

unwrapping of the optional's value. There is a method for avoiding forced unwrapping
which we will cover below.
In Swift, though, there are two ways to cast — one that’s safe and one that’s not .
as used for upcasting and type casting to bridged type
as? used for safe casting, return nil if failed
as! used to force casting, crash if failed. should only be used when we know the
downcast will succeed.
You can use zip to combine your two arrays, and thereafter apply a .flatMap to the tuple
elements of the zip sequence:

85-What is Helper Objects and Cluster Class?


Helper Objects: are used throughout Cocoa and CocoaTouch, and usually take the form
of a delegate or dataSource. They are commonly used to add functionality to an existing
class without having to subclass it.
Class clusters: are a design pattern that the Foundation framework makes extensive use
of. Class clusters group a number of private concrete subclasses under a public abstract
superclass. The grouping of classes in this way simplifies the publicly visible architecture
of an object-oriented framework without reducing its functional richness.

86-What is generics and the difference ANY and ANY OBJECT ?


Generics: features to write flexible and reusable functions and types. Generics are used to
avoid duplication and to provide abstraction. Swift standard libraries are built with generics
code. Swifts ‘Arrays’ and ‘Dictionary’ types belong to generic collections. With the help of
arrays and dictionaries, the arrays are defined to hold ‘Int’ values and ‘String’ values or any
other types.Generics are type safe, meaning if you pass a string as a generic and try to use
as a integer the compiler will complain and you will not be able to compile your. Because
Swift is using Static typing, and is able to give you a compiler error.

func add<T:Numeric>(number:T, number1:T) ->T


{
return number + number1
}

add(number:10, number1:20)

Any: can represent an instance of any type at all, including function types and optional
types.
AnyObject: can represent an instance of any class type.
Consider the following code:
var array = [AnyObject]()
struct Test {}
array.append(Test())
This code generates a compilation error, with the following error message:
Type 'Test' does not conform to protocol 'AnyObject'
The failure is obvious because a struct is a value and not a reference type, and as such it
doesn’t implement and cannot be cast to the AnyObject protocol.







Now consider the following code:


var array = [AnyObject]()
array.append(1)
array.append(2.0)
array.append("3")
array.append([4, 5, 6])
array.append([7: "7", 8: "8"])

struct Test {}
array.append(Test())
The array array is filled in with values of type respectively int, double, string, array and
dictionary. All of them are value types and not reference types, and in all cases no error is
reported by the compiler. Why?
Answer: The reason is that swift automatically bridges:
• number types to NSNumber
• strings to NSString
• arrays to NSArray
• dictionaries to NSDictionary
which are all reference types.
87-Differentiate Foundation vs Core Foundation
Foundation framework: defines a base layer of Objective-C classes. In addition to
providing a set of useful primitive object classes, it introduces several paradigms that
define functionality not covered by the Objective-C language. The Foundation
framework is designed with these goals in mind: · Provide a small set of basic utility
classes.Make software development easier by introducing consistent conventions for
things such as deallocation.Support Unicode strings, object persistence, and object
distribution.Provide a level of OS independence, to enhance portability.
CoreFoundation: is a general-purpose C framework whereas Foundation is a general-
purpose Objective-C framework. Both provide collection classes, run loops, etc, and
many of the Foundation classes are wrappers around the CF equivalents. CF is mostly
open-source , and Foundation is closed-source.
Core Foundation is the C-level API, which provides CFString, CFDictionary and the
like.Foundation is Objective-C, which provides NSString, NSDictionary, etc.
CoreFoundation is written in C while Foundation is written in Objective-C. Foundation
has a lot more classes CoreFoundation is the common base of Foundation and Carbon.

88- Readers-Writers
Multiple threads reading at the same time while there should be only one thread writing.
The solution to the problem is a readers-writers lock which allows concurrent read-only
access and an exclusive write access. Terminology;
Race Condition A race condition occurs when two or more threads can access
shared data and they try to change it at the same time.
Deadlock A deadlock occurs when two or sometimes more tasks wait for the other to
finish, and neither ever does.
Readers-Writers problem Multiple threads reading at the same time while there
should be only one thread writing.
































Readers-writer lock Such a lock allows concurrent read-only access to the shared
resource while write operations require exclusive access.
Dispatch Barrier Block Dispatch barrier blocks create a serial-style bottleneck
when working with concurrent queues.
89-Retain cycle or Retain loop.
Retain cycle:
The book has a strong reference to its pages and the page has a strong reference to the
book? Guess what happens next. That’s right, a memory leak.
A memory leak occurs when a content remains in memory even after its lifecycle has
ended.
In this case, the memory leak is caused by two strong variables that address each other. This
problem is known as the retain cycle problem.
Ok, now let’s see some solutions.
Just remember that now the book will be an optional and eventually it could become nil.

//Memoey Leak
class A
{
var b:B!
deinit
{
print("deinit of A")
}
}

class B
{
var a:A!
deinit
{
print("deinit of B")
}
}

do {
let a = A()
let b = B()
a.b = b
b.a = a
}

Retain loop: Objective-C’s garbage collector (when enabled) can also delete retain-
loop groups but this is not relevant on the iPhone, where Objective-C garbage
collection is not supported.

90-What’s your preference when writing UI’s, Xib files, Storyboards or programmatic
UIView?


There's no right or wrong answer to this, but it's great way of seeing if you understand the
benefits and challenges with each approach. Here's the common answers I hear:
• Storyboard's and Xib's are great for quickly producing UI's that match a design spec.
They are also really easy for product managers to visually see how far along a screen
is.
• Storyboard's are also great at representing a flow through an application and
allowing a high-level visualisation of an entire application.
• Storyboard's drawbacks are that in a team environment they are difficult to work on
collaboratively because they're a single file and merge's become difficult to manage.
• Storyboards and Xib files can also suffer from duplication and become difficult to
update. For example if all button's need to look identical and suddenly need a colour
change, then it can be a long/difficult process to do this across storyboards and xibs.
• Programmatically constructing UIView's can be verbose and tedious, but it can allow
for greater control and also easier separation and sharing of code. They can also be
more easily unit tested.
Most developers will propose a combination of all 3 where it makes sense to share code,
then re-usable UIViews or Xib files.

91-strong, weak, unsafe_unretained, autoreleasing, NSAutoReleasePool, release and


drain?
drain: releases the NSAutoreleasePool itself it have number of objects.
In a reference-counted environment, drain does perform the same operations as release, so
the two are in that sense equivalent. To emphasise, this means you do not leak a pool if you
use drain rather than release.
In a garbage-collected environment, release is a no-op. Thus it has no effect. drain, on the
other hand, contains a hint to the collector that it should “collect if needed”. Thus in a
garbage-collected environment, using drain helps the system balance collection sweeps.
Autorelease: By sending an object an autorelease message, it is added to the local
AutoReleasePool, and you no longer have to worry about it, because when the
AutoReleasePool is destroyed (as happens in the course of event processing by the system)
the object will receive a release message, its RetainCount will be decremented, and the
GarbageCollection system will destroy the object if the RetainCount is zero.
Release: retain count is decremented at this point and frees a memory of object..
Autorelease pools: provide a mechanism whereby you can send an object a “deferred”
release message. This is useful in situations where you want to relinquish ownership of
an object, but want to avoid the possibility of it being deallocated immediately (such as
when you return an object from a method).
Typically, you don’t need to create your own autorelease pools, but there are some
situations in which either you must or it is beneficial to do so.
Every time -autorelease is sent to an object, it is added to the inner-most autorelease
pool. When the pool is drained, it simply sends -release to all the objects in the
pool.Autorelease pools are simply a convenience that allows you too defer sending -
release until “later”. That “later” can happen in several places, but the most common in
Cocoa GUI apps is at the end of the current run loop cycle.
When you send an object a autorelease message, its retain count is decremented by 1 at
some stage in the future. The object is added to an autorelease pool on the current thread.





The main thread loop creates an autorelease pool at the beginning of the function, and
release it at the end. This establishes a pool for the lifetime of the task. However, this also
means that any autoreleased objects created during the lifetime of the task are not disposed
of until the task completes. This may lead to the task’s memory footprint increasing
unnecessarily.
Ball *ball = [[[[Ball alloc] init] autorelease] autorelease];
It will crash because it’s added twice to the autorelease pool and when it it dequeued
the autorelease pool calls release more than once.
1. If you are writing a program that is not based on a UI framework, such as a
command-line tool.
2.If you write a loop that creates many temporary objects.You may create an
autorelease pool inside the loop to dispose of those objects before the next iteration.
Using an autorelease pool in the loop helps to reduce the maximum memory
footprint of the application.
3. If you spawn a secondary thread.
The strong and weak are new ARC types replacing retain and assign
respectively.
Strong: reference is a reference to an object that stops it from being
deallocated. In other words it creates an owner relationship, strong is
the default so you don’t need to type it. This means any object created
using alloc/init is retained for the lifetime of its current scope. The
“current scope” usually means the braces in which the variable is
declared.
Weak: reference is a reference to an object that does not stop it from being
deallocated. In other words, it does not create an owner relationship.Delegates
and outlets should be weak, weak means the object can be destroyed at
anytime. This is only useful if the object is somehow strongly referenced
somewhere else. When destroyed, a variable with weak is set to nil.
A weak reference allows the possibility of it to become nil (this happens automatically
when the referenced object is deallocated), therefore the type of your property must be
optional - so you, as a programmer, are obligated to check it before you use it (basically the
compiler forces you, as much as it can, to write safe code).
unsafe_unretained/unowned weak: is just like weak but the pointer is not set to nil when
the object is deallocated. Instead the pointer is left dangling.
An unowned reference presumes that it will never become nil during its lifetime. An unowned
reference must be set during initialisation - this means that the reference will be defined as a non-
optional type that can be used safely without checks. If somehow the object being referred to is
deallocated, then the app will crash when the unowned reference will be used.
If self could be nil in the closure use [weak self].
If self will never be nil in the closure use [unowned self].
If it's crashing when you use [unowned self] then self is probably nil at some point in that closure
and you probably need to use [weak self] instead.

92-What is AutoLayout? What does it mean when a constraint is "broken" by iOS?



AutoLayout provides a flexible and powerful layout system that describes how views and
the UI controls calculates the size and position in the hierarchy.AutoLayout is way of laying
out UIViews using a set of constraints that specify the location and size based relative to
other views or based on explicit values. AutoLayout makes it easier to design screens that
resize and layout out their components better based on the size and orientation of a screen.
_Constraint_s include:
• setting the horizontal/vertical distance between 2 views
• setting the height/width to be a ratio relative to a different view
• a width/height/spacing can be an explicit static value
Sometimes constraints conflict with each other. For example imagine a UIView which has 2
height constraints: one says make the UIView 200px high, and the second says make the
height twice the height of a button. If the iOS runtime can not satisfy both of these
constraints then it has to pick only one. The other is then reported as being "broken" by
iOS.
93-A product manager in your company reports that the application is crashing. What
do you do?
This is a great question in any programming language and is really designed to see how you
problem solve. You're not given much information, but some interviews will slip you more
details of the issue as you go along. Start simple:
• get the exact steps to reproduce it.
• find out the device, iOS version.
• do they have the latest version?
• get device logs if possible.
Once you can reproduce it or have more information than start using tooling. Let's say it
crashes because of a memory leak, I'd expect to see someone suggest using Instruments
leak tool. A really impressive candidate would start talking about writing a unit test that
reproduces the issue and debugging through it.
Other variations of this question include slow UI or the application freezing. Again the idea
is to see how you problem solve, what tools do you know about that would help and do you
know how to use them correctly.

94-What makes React Native special for iOS?


Unlike PhoneGap)with React Native your application logic is written and runs in
JavaScript, whereas your application UI is fully native; therefore you have none of
the compromises typically associated with HTML5 UI.Additionally (unlike
Titanium), React introduces a novel, radical and highly functional approach to
constructing user interfaces. In brief, the application UI is simply expressed as a
function of the current application state.

95-Consider the following code:


var defaults = NSUserDefaults.standardUserDefaults()
var userPref = defaults.stringForKey("userPref")!
printString(userPref)

func printString(string: String) {


println(string)
}





























Where is the bug? What does this bug cause? What’s the proper way to fix it?
Answer: The second line uses the stringForKey method of NSUserDefaults, which returns
an optional, to account for the key not being found, or for the corresponding value not being
convertible to a string.
During its execution, if the key is found and the corresponding value is a string, the above
code works correctly. But if the key doesn’t exist, or the corresponding value is not a string,
the app crashes with the following error:
fatal error: unexpectedly found nil while unwrapping an Optional value
The reason is that the forced unwrapping operator ! is attempting to force unwrap a value
from a nil optional. The forced unwrapping operator should be used only when an optional
is known to contain a non-nil value.
The solution consists of making sure that the optional is not nil before force-unwrapping it:
let userPref = defaults.stringForKey("userPref")
if userPref != nil {
printString(userPref!)
}
An even better way is by using optional binding:
if let userPref = defaults.stringForKey("userPref") {
printString(userPref)
}

96-How should one handle errors in Swift?


In Swift, errors are thrown and handled inside of do-catch blocks.
The method for handling errors in Swift differ a bit from Objective-C. In Swift, it's possible
to declare that a function throws an error. It is, therefore, the caller's responsibility to handle
the error or propagate it. This is similar to how Java handles the situation.You simply
declare that a function can throw an error by appending the throws keyword to the function
name. Any function that calls such a method must call it from a try block.
func canThrowErrors() throws -> String

//How to call a method that throws an error


try canThrowErrors()
//Or specify it as an optional
let maybe = try? canThrowErrors()</pre>

97.Should I learn Swift or Objective-C and Differences Between Swift And


Objective-C?
Swift: Apple has made it clear that Swift is the cornerstone of the future of iOS
development. Plus, you can still utilise Objective-C files alongside Swift code, so you
won’t miss out on any pre-existing libraries and code.Apple boasts that Swift is up to 2.6x
faster than Objective-C and 8.4x faster than Python 2.7. And why should you care about
how quickly code executes? Well, faster running code makes for more efficient and
smoother running apps, which makes for a better experience for your user.
Objective-C: has been Apple’s primary programming language for app writing since OS X
was created. In that time, programming languages and practices changed drastically,
especially in mobile development. Rather than adopt a new, already existing language,
Apple created a new language tailored specifically for development on their own hardware.
















Swift is probably most similar in look and feel to Ruby or Python. Though you’ll also
probably recognise some C syntax.
1. Optionals
Optionals are a concept which doesn’t exist in C or Objective-C. They allow functions
which may not always be able to return a meaningful value (e.g. in the event of invalid
input) to return either a value encapsulated in an optional or nil. In C and Objective-C, we
can already return nil from a function that would normally return an object, but we don’t
have this option for functions which are expected to return a basic type such as int, float, or
double.
2. Control Flow
Anyone who’s programmed in C or a C-like language is familiar with the use of curly
braces ({}) to delimit code blocks. In Swift, however, they’re not just a good idea: they’re
the law!
3. Type Inference
Swift introduces type safety to iOS development. Once a variable is declared with a
particular type, its type is static and cannot be changed. The compiler is also smart enough
to figure out (or infer) what type your variables should be based on the values you assign
them.
4. Tuples
Swift supports tuples, values which store groups of other values. Unlike arrays, the values
in a tuple don’t have to all be the same type.
5. String Manipulation
Swift offers huge improvements over Objective-C in terms of string manipulation. For
starters, you don’t have to worry about mutable vs. immutable strings anymore: just declare
your string with var if you want to change it in the future, or with let if you need it to
remain constant.
6. Guard And Defer
We have guard, a new conditional statement which can make this code much more
readable. Guard stops program flow if a condition is not met:
Using defer inside a method means that its work will be executed as the method is exiting.
For example:
override func viewDidLoad() {
super.viewDidLoad()

print("Step 1")
myFunc()
print("Step 5")
}

func myFunc() {
print("Step 2")
defer { print("Step 3") }
print("Step 4")
}

That will print "Step 1", "Step 2", "Step 4", "Step 3", "Step 5" – steps 3 and 4 are switched
because 3 is deferred until the myFunc() method ends, i.e. when it goes out of scope
programmatically.
This scope is effectively anything in braces, { and }, but realistically there are two main
ways you may want to use it: inside a do block and inside a loop.
7. Functional Programming Patterns
Swift incorporates a number of functional programming features, such as map and filter,
which can be used on any collection which implements the CollectionType protocol:
8. Enumerations
In Swift, enumerations are more powerful than they ever were in Objective-C: they can
now contain methods and be passed by value.
9. Functions
Swift’s function syntax is flexible enough to define anything from a simple C-style function
to a complex Objective-C-style method with local and external parameter names.
Every function in Swift has a type, which consists of the function’s parameter types and
return type. This means you can assign functions to variables or pass them as parameters to
other functions:
10. Do Statement
The do statement in Swift allows you to introduce a new scope:
Do statements can also contain one or more catch clauses:
Difference between ‘C’ and ‘Swift’ language is that
Swift
• In a swift, the variable and constants are declared before their use
• You have to use “let” keyword for constant and “var” keyword for variable
• There is no need to end code with semi-colon
• Concatenating strings is easy in swift and allows to make a new string from a mix of
constants, literals, variables, as well as expressions
• Swift does not require to create a separate interface like Objective C. You can define
classes in a single file (.swift)
• Swift enables you to define methods in class, structure or enumeration
• In Swift, you use “ +=” Operator to add an item

Objective-C
• In objective C, you have to declare variable as NSString and constant as int
• In objective C, variable is declared as “ and constant as “
• The code ends with semi-colon
• In objective C, you have to choose between NSMutableString and NSString for
string to be modified.
• For classes, you create separate interface (.h) and implementation (.m) files for
classes
• Objective does not allow this
• In C, you use “addObject”: method of NSMutable array to append a new item to an
array

98.Subclass, Category and Extensions in Objective C


Category: is a feature of the Objective-C language that enables you to add methods
(interface and implementation) to a class without having to make a subclass. There is no





























runtime difference within the scope of your program between the original methods of the
class and the methods added by the category. The methods in the category become part of
the class type and are inherited by all the class’s subclasses.As with delegation, categories
are not a strict adaptation of the Decorator pattern, fulfilling the intent but taking a different
path to implementing that intent. The behaviour added by categories is a compile-time
artefact, and is not something dynamically acquired. Moreover, categories do not
encapsulate an instance of the class being extended.
You may implement categories in your code to extend classes without subclassing or to
group related methods. However, you should be aware of these caveats:
• You cannot add instance variables to the class.
• If you override existing methods of the class, your application may behave
unpredictably.
Subclass in Objective C:
Subclassing in simple words is changing the behaviour of properties or methods of an
existing class or in other words subclassing is inheriting a class and modifying the
methods or properties of super class however you want.
Extensions in Objective C:
Extensions are similar to categories but the need of extension is different.
- Class extensions are often used to extend the public interface with additional private
methods or properties for use within the implementation of the class.
- Extensions can only be added to a class for which you have the source code at compile
time (the class is compiled at the same time as the class extension).
- Extensions will be local to a class file.
Class extensions are similar to categories. The main difference is that with an extension,
the compiler will expect you to implement the methods within your main
@implementation, whereas with a category you have a separate @implementation block.
So you should pretty much only use an extension at the top of your main .m file (the only
place you should care about ivars, incidentally) it’s meant to be just that, an extension.
Usually people will use extensions to hide private information off a class without
exposing them to access from any other class.

99. What is an API


API is the acronym for Application Programming Interface, which is a software
intermediary that allows two applications to talk to each other. Each time you use an app
like Facebook, send an instant message, or check the weather on your phone, you’re using
an API.When you use an application on your mobile phone, the application connects to the
Internet and sends data to a server. The server then retrieves that data, interprets it, performs
the necessary actions and sends it back to your phone. The application then interprets that
data and presents you with the information you wanted in a readable way. This is what an
API is - all of this happens via API.

100.What is the biggest difference between NSURLConnection and NSURLSession?


NSURLConnection: if you suddenly realised you needed to do those things, you had to
refactor your code to not use block-based callbacks.if we have an open connection with
NSURLConnection and the system interrupt our App, when our App goes to background
mode, everything we have received or sent were lost.

Methods used in NSURLConnection:


(1)Connection did receive Response (2)Connection did receive Data
(3)Connection fail with error (4)Connection did finish loading.
NSURLSession: is designed around the assumption that you'll have a lot of requests that
need similar configuration (standard sets of headers, etc.), and makes life much easier if
you do.NSURLSession also provides support for background downloads, which make it
possible to continue downloading resources while your app isn't running (or when it is in
the background on iOS). For some use cases, this is also a major win.NSURLSession also
provides grouping of related requests, making it easy to cancel all of the requests associated
with a particular work unit, such as canceling all loads associated with loading a web page
when the user closes the window or tab.NSURLSession also provides nicer interfaces for
requesting data using blocks, in that it allows you to combine them with delegate methods
for doing custom authentication handling, redirect handling, etc.
In an application we usually works with
1 Data tasks – Data tasks are used for requesting data from a server, such as JSON
data. These data are usually stored in memory and never touches the File System We
can use NSURLSessionDataTask.
2 Upload Tasks – Upload tasks are used to upload data to a remote destination. We can
use NSURLSessionUploadTask.
3 Download Tasks – Downloading a file and Storing in a temporary location. We can
use NSURLSessionDownloadTask.

101.Explain and show examples of SOLID principles?


SOLID principles are relatively old but incredibly useful concepts to apply to any OOP
codebase in any language.
SOLID stands for Single Responsibility Principle, Open/Closed Principle, Liskov
Substitution Principle, Interface Segregation Principle, and Dependency Inversion
Principle. These principles feed into and support each other and are one of the best general
design approaches you could take for your code. Let’s go through each of them.
The Single Responsibility Principle (SRP) is the most important principle of the group. It
states that every module should have only one responsibility and reason to change. SRP
starts with small concrete and specific cases such as a class and/or an object having only
one purpose and being used only for only one thing.
The Open/Closed Principle (OCP) states that your modules should be open for extension
but closed for modification. It’s one of those things that sounds easy enough but is kind of
hard to wrap your head around when you start to think about what it means. Effectively it
means that when writing your code you should be able to extend the behaviour of your
objects through inheritance, polymorphism, and composition by implementing them using
interfaces, abstractions, and dependency injection.
The Liskov Substitution Principle (LSP) states that objects in a program should be
replaceable with instances of their subtypes without altering the correctness of that
program. What that means is that when you inherit from a class or an abstract class or
implement an interface (protocol), your objects should be replaceable and injectable
wherever that interface or class that you subclassed from was used. This principle is often
referred to as design by contract or, as of late in the Swift community, referred to as
protocol-oriented programming. The main message of this principle is that you should not
violate the contract that your interfaces you subclass from promise to fulfil, and that by






subclassing, those subclasses could be used anywhere that the superclass was previously
used.
The Interface Segregation Principle (ISP) says many client-specific interfaces are better
than one general-purpose interface. It also states that no client should be forced to depend
on and implemented methods it does not use. What that means is that when you create
interfaces (protocols) that your classes implement, you should strive for and depend on
abstraction over specificity, but not until it becomes a waste where you have to implement a
bunch of methods your new class doesn’t even use.
The Dependency Inversion Principle (DIP) states, “depend on abstractions, not
concretions.” The best example that showcases this principle is the Dependency Injection
(DI) technique. With the Dependency Injection technique, when you create an object, you
supply and inject all of its dependencies upon its initialisation or configuration rather than
let the object create or fetch/find its dependencies for itself.
SOLID principles are the bedrock of good OOP design. Applying these principles will help
you build better, more maintainable software. It is highly advised to be well versed in them
if you are applying to a senior iOS position.

102.What is data encapsulation, Polymorphism and Abstract?


Data encapsulation: encourages the use of methods to get and set the values of instance
variables in a class.But the developer to want to directly access an instance variable
without having to go through an accessor method.Data is contained within objects and is
not accessible by any other than via methods defined on the class is called data
encapsulation.Getters and setters are what make encapsulation elegant in most languages.
The point of getters and setters is to explicitly write self-documented code that prevents
accidental changes in your code. myObject.getSomeVar() and
myObject.setSomeVar("foo") explicitly tell whoever is maintaining your code (which can
and most of the time will include yourself) that your intentions are clear.
Polymorphism: Ability of base class pointer to call function from derived class at
runtime is called polymorphism.The word polymorphism means having many forms.
Typically, polymorphism occurs when there is a hierarchy of classes and they are
related by inheritance. Objective-C polymorphism means that a call to a member
function will cause a different function to be executed depending on the type of object
that invokes the function.
Abstract: Cocoa doesn’t provide anything called abstract. We can create a class abstract
which gets check only at runtime, compile time this is not checked.
@interface AbstractClass : NSObject
@end
@implementation AbstractClass
+ (id)alloc{
if (self == [AbstractClass class]) { NSLog(@”Abstract Class cant be used”); } return
[super alloc]; @end

103.Swift’s Equitable and Comparable Protocols

Equitable: relates too being equal, and “comparable” relates to the comparison
between objects. This is important, because how can we be certain that two complex
objects are the same? In many circumstances, this is something that you should decide.
Comparable: A protocol that can be applied to a type using the relational operators <,
<=, >=, and >
Equitable: A protocol that can be applied to a type to allow value equality
Operand: The value on which an operator is performed

104. Mention what is the characteristics of Switch Enums in Swift?


Switch:It supports any kind of data, and not only synchronise but also checks for equality,
when a case is matched in switch, the program exists from the switch case and does not
continue checking next cases. So you don’t need to explicitly break out the switch at the
end of case.Switch statement must be exhaustive, which means that you have to cover all
possible values for your variable, there is no fall through in switch statements and therefore
break is not required.
Enums:An enumeration defines a common type for a group of related values and
enables you to work with those values in a type-safe way within your
code.Enumerations in Swift are much more flexible, and do not have to provide a
value for each case of the enumeration. If a value (known as a “raw” value) is
provided for each enumeration case, the value can be a string, a character, or a value of
any integer or floating-point type.Enums can have methods, subscripts, and computed
properties. But it cannot have stored properties.Enum with Associated Values.

105.What is method swizzling in Objective C and why would you use it?
Method swizzling allows the implementation of an existing selector to be switched at
runtime for a different implementation in a classes dispatch table. Swizzling allows you to
write code that can be executed before and/or after the original method. For example
perhaps to track the time method execution took, or to insert log statements
#import "UIViewController+Log.h"
@implementation UIViewController (Log)
+ (void)load {
static dispatch_once_t once_token;
dispatch_once(&once_token, ^{
SEL viewWillAppearSelector = @selector(viewDidAppear:);
SEL viewWillAppearLoggerSelector = @selector(log_viewDidAppear:);
Method originalMethod = class_getInstanceMethod(self, viewWillAppearSelector);
Method extendedMethod = class_getInstanceMethod(self,
viewWillAppearLoggerSelector);
method_exchangeImplementations(originalMethod, extendedMethod);
});
}
- (void) log_viewDidAppear:(BOOL)animated {
[self log_viewDidAppear:animated];
NSLog(@"viewDidAppear executed for %@", [self class]);
}
@end

106.how to check crash reports client in iOS app?


Using TestFlight, Crashlytics, Firebase
TestFlight is a platform provided by Apple that allows you to send a testable version of your
app to specific beta users. It’s important to realise this is different than the App Store (which
is available to the general public). Once you send a user a TestFlight invitation, they must
download the TestFlight app where they can download and use a specific version of your
app for 60 days.
Now that our build is on iTunes Connect we need to set up Internal and/or External
TestFlight Testing.
After processing, select version no to send to tester, fill required information about what to
test, what types of testers or group app has to be sent for testing. After submit, after
sometime, tester will get email or may get notification about new build with version is
ready to test.

107.Property Observers
A property observer observes and responds to changes in a property’s value. With property
observer, we don’t need to reset the controls, every time attributes change.
There are two very appropriately named property observers in Swift: willSet, and didSet.
They are called exactly when you think they would be, right before and right after setting,
respectively. On top of this, they are also implicitly given constants describing the
newValue and oldValue respectively.
• willSet comes with a constant parameter that contains the new value, with the default
name newValue
• didSet comes with a constant parameter that contains the old value, with the default
name oldValue
You can override either of those names, if you wish, but if no name is provided, the defaults
are used.

108.Higher order functions in Swift?


Filter, Map, Reduce, flat map, compact Map, higher order functions are functions that
takes another function/closure as argument and returns it. You can use these functions
to operate on Swift collection types such as Array, set or Dictionary.
Map: The map function has a single argument which is a closure (a function) that it
calls as it loops over the collection. This closure takes the element from the collection
as an argument and returns a result. The map function returns these results in an array.
Filter: The filter method has a single argument that specifies the include condition.
This is a closure that takes as an argument the element from the collection and must
return a Bool indicating if the item should be included in the result.
Flat map: is used to flatten a collection of collections. But before flattening the
collection, we can apply map to each element.Even more usefully it knows about
optional and will remove them from a collection.
Compact Map: If you do compact map a collection containing optional values, it will
only consider the non-nil values. This doesn’t do anything on sets and dictionaries as
Sets cannot have nil values and for dictionary, the compact map will give an array of
tuples with key and value.
Reduce: So, the reduce function takes two arguments.




• One is an initial value which is used to store the initial value or the value or result
returned by the closure from each iteration.
• The other one is a closure which takes two arguments, one is the initial value or the
result from the previous execution of the closure and the other one is the next item in
the collection.
Use Higher order functions where ever possible:
• It improves your swift skills.
• Enhances readability of code.
• More functional programming.
Sort:
let numbers=[4,6,2,5,1,3]
let reverse=numbers.sorted{$0>$1}
print(reverse)

109.Apple Push Notification Services?


The device ID and UDID are different names for the same thing. The device token is used
for a server to send notifications to that device using Apple's Push Notification service - it
lets the APN server know which device you're talking about, but doesn't have any meaning
outside that context.
There are two steps to get device token. First, we must show the user’s permission screen,
after we can register for remote notifications. If these steps go well, the system will provide
device token. If we uninstall or reinstall the app, the device token would change.
1 An app enables push notifications. The user has to confirm that he wishes to receive
these notifications.
2. The app receives a “device token”. You can think of the device token as the
address that push notifications will be sent to.
3. The app sends the device token to your server.
4. When something of interest to your app happens, the server sends a push
notification to the Apple Push Notification Service, or APNS for short.
5. APNS sends the push notification to the user’s device.
When the user’s device receives the push notification, it shows an alert, plays a sound and/
or updates the app’s icon. The user can launch the app from the alert. The app is given the
contents of the push notification and can handle it as it sees fit.
We can be sent with video or image with push notification. But maximum payload is 4kb. If
we want to sent high quality attachment, we should use Notification Service Extension.

110.What is Concurrency and Objectives of Concurrency?


Concurrency:
• Doing multiple things at the same time.
• Taking advantage of number of cores available in multicore CPUs.
• Running multiple programs in parallel.
Objectives of Concurrency:
• Running program in background without hogging CPU.
• Define Tasks, Define Rules and let the system take the responsibility of performing
them.
• Improve responsiveness by ensuring that the main thread is free to respond to user
events.
• Leverage more cores to do more work in the same amount of time.

111.Operations, Operation Queue and Grand Central Dispatch synchronous versus


asynchronous connections.
asynchronous: NSOperation is an OOP abstraction on top of GCD that allows you to do
more sophisticated async operations, but everything you could achieve with NSOperations
you could do with GCD. Many Cocoa frameworks use GCD and/or NSOperations under
the hood (NSURLSession for example).
There are alternative ways of handling async work using third-party libraries’ help. The
most notable are Promises (PromiseKit), RxSwift, and ReactiveCocoa. RxSwift and
ReactiveCocoa are especially good at modelling the asynchronous nature of time and work
that needs to be done in the background and coordinated among threads,You don’t have to
create a new thread for the connection because your main thread will not be blocked.You
can easily cancel the connection just by calling the cancel method.If you need
authentication just implement the required delegate methods.Parsing data on the fly is
easy.So clearly we have a lot of more control with this, and the code is really not
difficult.Even better, we don’t have to handle the creation of a new thread, which is a good
thing, because you know, threading is hard.Well, if you read me until here, you should be
convinced to use asynchronous connections, and forget about synchronous ones. They
clearly give us more control and possibilities and, in some case can spare us to create new
thread.So I encourage you to move away from synchronous connections, just think of them
as evil..
synchronous: The most important problem is that the thread which called this method will
be blocked until the connection finish or timeout, so we surely don’t want to start the
connection on the main thread to avoid freezing the UI. That means we need to create a new
thread to handle the connection, and all programmers know that threading is
hard.Cancellation, it’s not possible to cancel a synchronous connection, which is bad
because users like to have the choice to cancel an operation if they think it takes too much
time to execute.Authentication, there is no way to deal with authentication challenges.It’s
impossible to parse data on the fly.So let’s put it up straight, avoid using
synchronousNSURLConnection, there is absolutely no benefit of using it.
Threads: are especially useful when you need to perform a lengthy task, but don’t want it
to block the execution of the rest of the application. In particular, you can use threads to














avoid blocking the main thread of the application, which handles user interface and event-
related actions. Threads can also be used to divide a large job into several smaller jobs,
which can lead to performance increases on multi-core computers.The problem with
signals is not what they do, but their behaviour when your application has multiple threads.
In a single-threaded application, all signal handlers run on the main thread. In a
multithreaded application, signals that are not tied to a specific hardware error (such as an
illegal instruction) are delivered to whichever thread happens to be running at the time. If
multiple threads are running simultaneously, the signal is delivered to whichever one the
system happens to pick. In other words, signals can be delivered to any thread of your
application.
Threads are still a good way to implement code that must run in real time
• Dispatch Queues make every attempt to run their tasks as fast as possible but they do
not address the real time constraints
• Threads are low level tool that needs to be managed manually.
• Creating a correct threading solution is difficult.
• Thread synchronisation adds complexity to the project
• Incorrectly implemented threading solution might make the system even worse
• Scalability is an issue when it comes to utilising multiple available cores.
• Object oriented way to encapsulate work that needs to be performed asynchronously
• An Operation object is an instance of NSOperation(abstract) class.
• NSOperation class has two concrete subclasses that can be used as is
• NSInvocationOperation (used to execute a method)
• NSBlockOperation (used for executing one or more blocks concurrently)
• An operation can be executed individually/manually by calling its start method or it
can be added to an OperationQueue.

NSInvocationOperation:
• A class we can use as-is to create an operation object based on an object and selector
from your application.
• We can use this class in cases where we have an existing method that already
performs the needed task. Because it does not require subclassing, we can also use
this class to create operation objects in a more dynamic fashion.

NSBlockOperation:
• A class we use as-is to execute one or more block objects concurrently.
• Because it can execute more than one block, a block operation object operates using
a group semantic; only when all of the associated blocks have finished executing is
the operation itself considered finished.
Grand Central Dispatch: provides queues to which the application can submit tasks in the
form of block objects. The block of code submitted to dispatch queues are executed on a
pool of threads managed by the system. Each task can either be executed synchronously or
asynchronously. In case of synchronous execution the program waits for the execution to be
finished before the call returns. In case of asynchronous call the method call returns
immediately.Dispatch Queues can be serial or concurrent. In case of serial dispatch queues
the work items are executed one at a time and in case of concurrent although the tasks are
dequeued in order but they run in parallel and can finish in any order. Grand Central
Dispatch is ideal if you just need to dispatch a block of code to a serial or concurrent
































queue.If you don’t want to go through the hassle of creating an NSOperation subclass for a
trivial task, then Grand Central Dispatch is a great alternative. Another benefit of Grand
Central Dispatch is that you can keep related code together. GCD is a library that provides a
low-level API to run tasks concurrently while managing threads behind the scenes.
Terminology.Dispatch Queues, A dispatch queue is responsible for executing a task in the
first-in, first-out order.
Serial Dispatch Queue A serial dispatch queue runs tasks one at a time.
Concurrent Dispatch Queue A concurrent dispatch queue runs as many tasks as it can
without waiting for the started tasks to finish.
Main Dispatch Queue A globally available serial queue that executes tasks on the
application’s main thread.
Main Queue: When the app is launched the system automatically creates a special queue
called as main queue. Work items on the main queue is executed serially on the applications
main thread.
NSOperationQueue: class regulates the execution of a set of NSOperation objects. An
operation queue is generally used to perform some asynchronous operations on a
background thread so as not to block the main thread.
NSOperation: API is great for encapsulating well-defined blocks of functionality. You
could, for example, use an NSOperation subclass to encapsulate the login sequence of an
application.Dependency management is the icing on the cake. An operation can have
dependencies to other operations and that is a powerful feature Grand Central Dispatch
lacks. If you need to perform several tasks in a specific order, then operations are a good
solution.You can go overboard with operations if you are creating dozens of operations in a
short timeframe. This can lead to performance problems due to the overhead inherent to the
NSOperation API.

112.What considerations do you need when writing a UITableViewController which


shows images downloaded from a remote server?
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.
Other good answers will go on to talk about offline caching of the images, using
placeholder images while the images are being downloaded.

113. Difference between struct and class swift


Both class and structure can do:

• Define properties to store values


• Define methods to provide functionality












• Be extended
• Conform to protocols
• Define initialisers
• Define Subscripts to provide access to their variables
Only class can do:

• Inheritance
• Type casting
• Define de initialisers
• Allow reference counting for multiple references.

1.One of the most important differences between structures and classes is that
structures are value types and are always copied when they are passed
around in your code, and classes are reference type and are passed by
reference.
2. Also, classes have Inheritance which allows one class to inherit the
characteristics of another.
3. Struct properties are stored on Stack and Class instances are stored on Heap
hence, sometimes the stack is drastically faster than a class.
4. Struct gets a default initialiser automatically whereas in Class, we have to
initialise.
5. Struct is thread safe or singleton at any point of time.
And also, To summarise the difference between structs and classes, it is necessary to
understand the difference between value and reference types.

1. When you make a copy of a value type, it copies all the data from the thing you
are copying into the new variable. They are 2 separate things and changing
one does not affect the other.
2. When you make a copy of a reference type, the new variable refers to the same
memory location as the thing you are copying. This means that changing
one will change the other since they both refer to the same memory location.

114. What are some ways to support newer API methods or classes while maintaining
backward compatibility?
1. Set the Base SDK to Current version of Mac (ex. 10.7)
2. Set the Deployment SDK to older version (ex.1.4)
For instance, if you want your view to have a red tintColor (a method introduced in iOS 7),
but your app still supports iOS 6, how could you make sure it won’t crash when running on
iOS 6?
Treat deprecated APIs warnings as errors to resolve.At runtime, check for OS
versions.Control the number of 3d party libraries.objC : Mark legacy code paths with
macros.
if #available(iOS 8, *, *) {
self.view.convertPoint(.Zero, toCoordinateSpace:anotherView)
} else {

self.view.convertPoint(CGPointZero, toView:anotherView)
}

115. In Swift, what are fail-able, throwing initialisers and Tuples?


Very often initialisation depends on external data, this data can exist as it can not, for that
Swift provides two ways to deal with this.
Fail-able initialisers: return nil of there is no data, and let the developer “create” a
different path in the application based on that.
Throwing initialisers: returns an error on initialisation instead of returning nil.
Tuples: are simply ordered sets of values and for our purposes, they group multiple values
into a single compound value.

let names=(name:"sandeep", lastname:"challa")


print(names.0)

Why is this important? In Objective-C, if you want a method to return more than one
value you have two options  return a custom object with properties that store your return
values or stick those values in a dictionary. With Swift however, we can use tuples to return
more than one value. The values in a tuple can be off any type and don’t have to be the
same type as each other.Tuples are value types. When you initialise a variable tuple with
another one it will actually create a copy.

116. What is an “app ID”, “bundle ID” , App Bundle and Signing?
bundle ID: is the identifier of a single app. For example, if your organisations domain is
xxx.com and you create an app named Facebook, you could assign the string
com.xxx.facebook as our app’s bundle ID.
App ID: is a two-part string used to identify one or more apps from a single development
team. You need Apple Developer account for an App ID.
App Bundle: When you build your iOS app, Xcode packages it as a bundle. App bundle is
a directory in the file system that groups related resources together in one place. An iOS
app bundle contains the app executable file and supporting resource files such as app icons,
image files, and localised content.
Signing: our app allows iOS to identify who signed our app and to verify that our app
hasn’t been modified since you signed it. The Signing Identity consists of a public-private
key pair that Apple creates for us.

117. if let, if var, guard let, guard var and defer statements in swift
Optional Binding (if -let statements) :
Use optional binding to find out whether an optional contains a value, and if so, to make
that value available as a temporary constant or variable.
An optional binding for the if statement is as follows −
If let constantName = someOptional {
//statements using 'constantName'
} else {
// the value of someOptional is not set (or nil).
}



Optional binding is the recommended way of unwrapping optionals.This method is safer


than force unwrapping and implicit unwrapping.
if -var statements :
If you use the let then you will not be able to change myValue.
if let myValue = myObject.value as NSString? {
myValue = "Something else" // <-- Compiler error
}
On the other hand with var you can.
Please note that myValue does exists only within the scope of the if and changing its value
does not produce effect outside of its scope. So, in most cases the if- var statement will be
useless.The drawback of if let and if var statements are that any variables or constants that
were assigned values using an optional binding are available only within the scope of the if
statement brackets.
Guard Statement :
Guard statement is simple and powerful. It checks for some condition and if it evaluates to
be false, then the else statement executes which normally will exit a method .
A guard let statement is another way off writing an if let statement written in a different
way. You use a guard statement to require that a condition must be true in order for the code
after the guard statement to be executed. Unlike an if statement, a guard statement always
has an else clause the code inside the else clause is executed if the condition is not true.
A guard block only runs if the condition is false, and it will exit out of the code block
through a control transfer statement like return, break, continue, or fall thrown. It
provides an early exit and fewer brackets. Early exit means faster execution.

118.Please explain Access Levels in Swift?


The Five Access Levels of Swift 4
To recap Swift 4 has the same five access levels as Swift 3. In order from most open to
most restricted:
• open you can access open classes and class members from any source file in the
defining module or any module that imports that module. You can subclass an open
class or override an open class member both within their defining module and any
module that imports that module.
• public allows the same access as open - any source file in any module - but has more
restrictive subclassing and overriding. You can only subclass a public class within
the same module. A public class member can only be overridden by subclasses in the
same module. This is important if you are writing a framework. If you want a user of
that framework to be able to subclass a class or override a method you must make it
open.
• internal allows use from any source file in the defining module but not from outside
that module. This is the default access level.
• file-private allows use only within the defining source file.
• private allows use only from the enclosing declaration and new in Swift 4, to any
extensions of that declaration in the same source file.
. final Use final when you know that a declaration does not need to be overridden. The
final keyword is a restriction on a class, method, or property that indicates that the
declaration cannot be overridden. This allows the compiler to safely elide dynamic
dispatch indirection.





Notes:
• Remember that your application target is its own module and that internal access is
the default. Your classes, structs, enums, properties and methods are all accessible
within the application module by default unless you choose to restrict access.
• As with Swift 3 you can add final to any access level, except open, to prevent
subclassing or overriding of a class method or property.

119. networking, Get, Post, REST, HTTP, HTTPs, JSON  What’s that?
networking: Every application these days uses networking to get data from APIs and other
external resources. Many apps are useless when not connected to the internet. Every iOS
developer should know what’s available to them to build the service/networking layer of
their application.
GET: method will be showing the information information to the users. The data passed
using the GET method would be visible to the user of the website in the browser
address bar, characters were restricted only to 256, will be visible to the user as it
sended appended to the URL,About the data type that can be send, with Get method
you can only use text as it sent as a string appended with the URL, About form
default, Get is the default method for any form, has limitation in the size of data
transmitted.

POST: method information will not be shown to the user.when we pass the information
using the POST method the data is not visible to the user directly, characters were
not restricted, will not be visible as it is sent encapsulated within the HTTP request
body.About the data type that can be send, with Post method you can use text or
binary as it sent as a string appended with the URL, if you need to use the post
method, you have to change the value of the attribute "method" to be Post, has no
limitation in the size of data transmitted

HTTPS: is HyperText Transfer Protocol Secure.HTTPS provides encrypted


communication, so that only the recipient can decrypt and read the information. Basically,
HTTPS is a combination of HTTP andSSL (Secure Sockets Layer). This SSL is that
protocol which encrypts the data. it is slow and expensive, safe it’s widely used during
payment transactions or any sensitive transactions over the internet.while HTTPS URLs
stars with “https:// “ and use port 443.HTTPS is secure from these sorts of attacks.
HTTP: is the application protocol, In iOS there are several options to implement HTTP
networking. You can go with good old NSURLSession, but unless you abstract it out well
enough, it can be daunting to work with. Another option would be to use a wrapper library
around it. The most popular solution on iOS is Alamofire. Alamofire provides chainable
request/response methods, JSON parameter and response serialisation, authentication, and
many other features.In general, if you have a small team you likely want to rely on open
sourced solutions such as Alamofire that abstract a lot of boilerplate code out for you; but if
you’re in a big team and can spare resources you’d want have more control over how data
is passed to/from your server and implement it yourself using NSURLSession.Senior
developers should keep in mind that building the networking layer in iOS applications
means not only dealing with HTTP requests but implementing the whole set of tasks your
code does related to that: HTTP networking, data serialisation, and data mapping.




These days, NSURLSession and Codable are the two main technologies used for
networking on iOS but also knowing about open source solutions such as Alamofire is
beneficial.
HTTP stands for HyperText Transfer Protocol, transmits everything as plan text, it is fast
and cheap, HTTP is used most of the sites over the net, even this blogspot sites also use
HTTP, HTTP URLs starts with “http:// “ and use port 80 by default.HTTP is unsafe from
attacks like man-in-the-middle and eavesdropping or set of rules, web sites use to transfer
data from the web server to client. The client (your web browser or app) use to indicate the
desired action:
GET: Used to retrieve data, such as a web page, but doesn’t alter any data on the
server.
HEAD: Identical to GET but only sends back the headers and none of the actual
data.
POST: Used to send data to the server, commonly used when filling a form and
clicking submit.
PUT: Used to send data to the specific location provided.
DELETE: Deletes data from the specific location provided.
REST: or Representational State Transfer, is a set of rules for designing consistent, easy-to-
use and maintainable web APIs.
JSON: stands for JavaScript Object Notation; it provides a straightforward, human-
readable and portable mechanism for transporting data between two systems. Apple
supplies the JSONSerialization class to help convert your objects in memory to JSON and
vice-versa.
mutableContainers :Specifies that arrays and dictionaries are created as variables objects,
not constants.
mutableLeaves: Specifies that leaf strings in the JSON object graph are created as
instances of variable String.
allowFragments: Specifies that the parser should allow top-level objects that are not
an instance of Array or Dictionary.

120.List out what are the control transfer statements used in Swift?
Control transfer statements used in Swift includes
• Continue
• Break
• Fall through
• Return

121.What is Property?
Swift 4 language provides properties for class, enumeration or structure to associate values.
Properties can be further classified into Stored properties and Computed properties.
Difference between Stored Properties and Computed Properties
Stored Property Computed Property
Store constant and variable values as Calculate a value rather than storing the
instance value
Provided by classes and structures Provided by classes, enumerations and
structures






















Both Stored and Computed properties are associated with instances type. When the
properties are associated with its type values then it is defined as 'Type Properties'.
Stored and computed properties are usually associated with instances of a particular
type. However, properties can also be associated with the type itself. Such properties
are known as type properties. Property observers are also used
To observe the value of the stored properties
Stored Properties:
Swift 4 introduces Stored Property concept to store the instances of constants and
variables. Stored properties of constants are defined by the 'let' keyword and Stored
properties of variables are defined by the 'var' keyword.
During definition Stored property provides 'default value'
During Initialisation the user can initialise and modify the initial values
Note: Unlike stored properties, Swift requires you to use an explicit type with your
computed properties.
Lazy Stored Property:
Swift 4 provides a flexible property called 'Lazy Stored Property' where it won't
calculate the initial values when the variable is initialised for the first time. 'lazy'
modifier is used before the variable declaration to have it as a lazy stored
property.Lazy Properties are used to delay object creation.
When the property is dependent on other parts of a class, that are not known yet
Computed Properties.Rather then storing the values computed properties provide a
getter and an optional setter to retrieve and set other properties and values
indirectly.Lazy stored properties are used for a property whose initial values is not
calculated until the first time it is used. You can declare a lazy stored property by
writing the lazy modifier before its declaration. Lazy properties are useful when the
initial value for a property is reliant on outside factors whose values are unknown.
Bonus Tip : You do need to declare your lazy property using the var keyword, not the let
keyword, because constants must always have a value before initialization completes.
Benefit of lazy property increase performance in terms of speed.
Computed Properties as Property Observers:
In Swift 4 to observe and respond to property values Property Observers are used.
Each and every time when property values are set property observers are called.
Except lazy stored properties we can add property observers to 'inherited' property by
method 'overriding'.
Property Observers can be defined by either
Before Storing the value - will set
After Storing the new value - did set
When a property is set in an initialiser will set and did-set observers cannot be called.
In addition to stored properties, classes, structures, and enumerations can define computed
properties, which do not actually store a value. Instead, they provide a getter and an
optional setter to retrieve and set other properties and values indirectly.

122. What are the most important application delegate methods a developer should
handle ?
The operating system calls specific methods within the application delegate to facilitate
transitioning to and from various states. The seven most important application delegate
methods a developer should handle are:

application:willFinishLaunchingWithOptions:
Method called when the launch process is initiated. This is the first opportunity to execute
any code within the app.
application:didFinishLaunchingWithOptions:
Method called when the launch process is nearly complete. Since this method is called is
before any of the app’s windows are displayed, it is the last opportunity to prepare the
interface and make any final adjustments.
applicationDidBecomeActive:
Once the application has become active, the application delegate will receive a callback
notification message via the method applicationDidBecomeActive.
This method is also called each time the app returns to an active state from a previous
switch to inactive from a resulting phone call or SMS.
applicationWillResignActive:
There are several conditions that will spawn the applicationWillResignActive method. Each
time a temporary event, such as a phone call, happens this method gets called. It is also
important to note that “quitting” an iOS app does not terminate the processes, but rather
moves the app to the background.
applicationDidEnterBackground:
This method is called when an iOS app is running, but no longer in the foreground. In other
words, the user interface is not currently being displayed. According to Apple’s
UIApplicationDelegate Protocol Reference, the app has approximately five seconds to
perform tasks and return. If the method does not return within five seconds, the application
is terminated.
applicationWillEnterForeground:
This method is called as an app is preparing to move from the background to the
foreground. The app, however, is not moved into an active state without the
applicationDidBecomeActive method being called. This method gives a developer the
opportunity to re-establish the settings of the previous running state before the app becomes
active.
applicationWillTerminate:
This method notifies your application delegate when a termination event has been triggered.
Hitting the home button no longer quits the application. Force quitting the iOS app, or
shutting down the device triggers the applicationWillTerminate method. This is the
opportunity to save the application configuration, settings, and user preferences.

123. How do you debug and profile code on iOS?


No one writes perfect code, and developers need to debug their code and profile apps for
performance and memory leaks.
There’s always NSLogging and printing in iOS apps. There are breakpoints you can set
using Xcode. For performance of individual pieces of code, you could use XCTest’s
measureBlock.You can do more advanced debugging and profiling using Instruments.
Instruments is a profiling tool that helps you profile your app and find memory leaks and
performance issues at runtime.Instrument is a powerful performance tuning tool to analyse
that performance, memory footprint, smooth animation, energy usage, leaks and file/
network activity.

124. What is three triggers for a local notification and use of UserNotifications?

Location, Calendar, and Time Interval. A Location notification fires when the GPS on your
phone is at a location or geographic region. Calendar trigger is based on calendar data
broken into date components. Time Interval is a count of seconds until the timer goes off.
We can add audio, video and images.
We can create custom interfaces for notifications.
We can manage notifications with interfaces in the notification centre.
New Notification extensions allow us to manage remote notification payloads before
they’re delivered.

125. nil / Nil / NULL / NSNull


NULL: literal null value for C pointers
nil: literal null value for Objective-C objects
Nil: literal null value for Objective-C objects
NSNull: singleton object used to represent null

126. What is the difference between functions and methods in Swift?


Functions are self-contained chunks of code that perform a specific task. You give a
function a name that identifies what it does, and this name is used to “call” the function to
perform its task when needed. With functions, there is no self.
Methods are functions that are associated with a particular type. Classes, structures, and
enumerations can all define instance methods, which encapsulate specific tasks and
functionality for working with an instance of a given type. The method can access self.
func someFunc{
//some code
}

class someClass{

func someMethod{
//some code
}

127.What are optional binding and optional chaining in Swift?


Optional bindings or chaining come in handy with properties that have been declared as
optional. Consider this example:
class Student {
var courses : [Course]?
}
let student = Student()
Optional chaining:
If you were to access the courses property through an exclamation mark (!) , you would end
up with a runtime error because it has not been initialised yet. Optional chaining lets you
safely unwrap this value by placing a question mark (?), instead, after the property, and is a
way of querying properties and methods on an optional that might contain nil. This can be
regarded as an alternative to forced unwrapping.
Optional binding:



Optional binding is a term used when you assign temporary variables from optionals in the
first clause of an if or while block. Consider the code block below when the property
courses have yet not been initialised. Instead of returning a runtime error, the block will
gracefully continue execution.
if let courses = student.courses {
print("Yep, courses we have")
}
The code above will continue since we have not initialised the courses array yet. Simply
adding:
init() { courses = [Course]() }
Will then print out "Yep, courses we have.”

128. What's the syntax for external parameters?


The external parameter precedes the local parameter name.
func yourFunction(externalParameterName localParameterName :Type, ....) { .... }
A concrete example of this would be:
func sendMessage(from name1 :String, to name2 :String) { print("Sending message from \
(name1) to \(name2)") }

129.Would you consider yourself a Swift expert?


This is a trick question. Because Swift is still being improved, the only true “Swift Experts”
are the people who developed it at Apple. Even if you’ve produced lots of great apps and
mastered a number of advanced courses and tutorials, you simply can’t be an expert at this
point. Remember, Swift has only been around from sometime. If your interviewer asks this,
argue that you could not possibly be an expert until the language is finished. Explain how
you, like most other iOS Developers, are constantly learning.

130.What are blocks and how are they used?


Blocks are a way of defining a single task or unit of behaviour without having to write an
entire Objective-C class. Under the covers Blocks are still Objective C objects. They are a
language level feature that allow programming techniques like lambdas and closures to be
supported in Objective-C. Creating a block is done using the ^ { } syntax:
myBlock = ^{
NSLog(@"This is a block");
}
It can be invoked like so:
myBlock();
It is essentially a function pointer which also has a signature that can be used to enforce
type safety at compile and runtime. For example you can pass a block with a specific
signature to a method like so:
- (void)callMyBlock:(void (^)(void))callbackBlock;
If you wanted the block to be given some data you can change the signature to include
them:
- (void)callMyBlock:(void (^)(double, double))block {
...
block(3.0, 2.0);
}

131.What is the difference Non-Escaping and Escaping Closures ?


The lifecycle of a non-escaping closure is simple:
Pass a closure into a function
The function runs the closure (or not)
The function returns
Escaping closure means, inside the function, you can still run the closure (or not); the extra
bit of the closure is stored some place that will outlive the function. There are several ways
to have a closure escape its containing function:
Asynchronous execution: If you execute the closure asynchronously on a dispatch
queue, the queue will hold onto the closure for you. You have no idea when the
closure will be executed and there’s no guarantee it will complete before the function
returns.
Storage: Storing the closure to a global variable, property, or any other bit of storage
that lives on past the function call means the closure has also escaped.
Capture List:
Unfortunately, the implementation used in “Default Variable Capture” has a problem. If we
change the value of some calculator properties before calling the closure, the sum inside the
closure is no longer 8 but it’s the sum of the new properties values:
var calculator = Calculator(a: 3, b: 5)

let closure = {
print("The result is \(calculator.sum)")
}

calculator.b = 20

closure() // Prints "The result is 23"


If we want to prevent this behaviour and print 8 even if the properties change after their
capturing inside the closure, we can explicitly capture the variable with a capture list like
this:
let closure = { [calculator] in
print("The result is \(calculator.sum)")
}
In this way, we keep an immutable copy of the variable calculator. Thanks to this copy,
further changes to calculator, outside the closure, will not affected the closure.
We can capture several variables in the same closure, separating them with a comma:
let closure = { [variable1, variable2, variable3] in
print(variable1)
print(variable2)
print(variable3)
}
Note
Since the variables inside the capture list are immutable, they are just read-only. It means
that we cannot change the value of calculator inside the closure:
let closure = { [calculator] in
calculator = Calculator(a: 1, b: 2) // Throws compile error





print("The result is \(calculator.sum)")


}

132.What is the difference SVN and Git ?


SVN: relies on a centralised system for version management. It’s a central repository where
working copies are generated and a network connection is required for access.
Git: relies on a distributed system for version management. You will have a local repository
on which you can work, with a network connection only required to synchronise.

133.What is the difference between LLVM and Clang?


Clang is the front end of LLVM tool chain ( “clang” C Language Family Frontend for
LLVM ). Every Compiler has three parts .
1. Front end ( lexical analysis, parsing )
2. Optimiser ( Optimising abstract syntax tree )
3. Back end ( machine code generation )
Front end ( Clang ) takes the source code and generates abstract syntax tree ( LLVM IR ).

134.How many different ways to pass data in Swift ?


There are many different ways such as Delegate, KVO, Segue, and NSNotification, Target-
Action, Callbacks.

135. What kind of benefits does Xcode server and Xcode Bot have for developers ?
Xcode server will automatically check out our project, build the app, run tests, and archive
the app for distribution.
Xcode Server uses bots to automatically build your projects. A bot represents a single
remote repository, project, and scheme. We can also control the build configuration the bot
uses and choose which devices and simulators the bot will use.

136.What are layer objects and Explain unwind segue?


Layer objects: are data objects which represent visual content and are used by views to
render their content. Custom layer objects can also be added to the interface to implement
complex animations and other types of sophisticated visual effects.
unwind segue: moves backward through one or more segues to return the user to a scene
managed by an existing view controller.

137.How to convert Swift String into an Array?


let Ustring : String = "iOS Developer Questions"
let characters = Array(Ustring.characters)
print(characters)

138.why swift is protocol oriented language


Protocol-Oriented Programming is a new programming paradigm ushered in by Swift
2.0. In the Protocol-Oriented approach, we start designing our system by defining
protocols. We rely on new concepts: protocol extensions, protocol inheritance, and
protocol compositions. The paradigm also changes how we view semantics. In Swift,
value types are preferred over classes. However, object-oriented concepts don’t work
well with structs and enums: a struct cannot inherit from another struct, neither can an

enum inherit from another enum. So inheritance one of the fundamental object-
oriented concepts cannot be applied to value types. On the other hand, value types can
inherit from protocols, even multiple protocols. Thus, with POP, value types have
become first class citizens in Swift.
Swift does not allow multiple inheritance for classes. However, Swift types can adopt
multiple protocols. Sometimes you may find this feature useful. You’ll also see how
the Swift team was able to use protocol extensions to improve the Swift standard
library itself, and how it impacts the code you write.
Swift supports multiple paradigms: Object-Oriented Programming, Protocol Oriented
Programming and Functional Programming.
The following diagram shows the class hierarchy for our Object-Oriented design:

This diagram shows that we have one superclass named Animal and two subclasses named
Alligator and Lion. We may think that, with the three categories, we would need to create a
larger class hierarchy where the middle layer would contain the classes for the Land, Air
and Sea animals however that is not possible with our requirements. The reason this is not
possible is because animal types can be members of multiple categories and with a class
hierarchy each class can have only one super class. This means that our Animal super class
will need to contain the code required for each of the three categories. Let's take a look at
the code for the Animal super class.
As we can see in these classes we override the functionality needed for each animal. The
Lion class contains the functionality for a land animal and the Alligator class contains the
functionality for both a land and sea animal. Since both class have the same Animal
superclass we can use polymorphism to access them through the interface provided by the
Animal superclass. Let's see how we would do this.
How we designed the animal types here would definitely work but there are several
drawbacks to this design. The first drawback is the large monolithic Animal superclass.
For those that are familiar with designed characters for video games you probably realise
how much functionality is actually missing form the Animal superclass and it’s subclasses.
This is on purpose so we can focus on the design and not all of the functionality. For those
who are not familiar with designed characters for video games, trust me when I say that this
class will get much bigger when we add all of the functionality needed.
Another drawback is not being able to define constants in the superclass that the subclasses
can set. We could define an initiator in the superclass that would set all of the constants
however the initiator would become pretty complex and that is something we would like to
avoid. The builder pattern could help us with the initiation but as we are about to see, a
protocol-oriented design would be even better.
One final drawback that I am going to point out is the use of flags (landAnimal, seaAnimal
and airAnimal properties) to define the type of animal. If we accidentally set these flags
wrong then the animal will not behave correctly. As an example, if we set the seaAnimal

flag rather than the landAnimal flag in the Lion class than the lion would not be able to
move or attack on land. Trust me it is very easy even for the most experience developer to
set flags like these wrong.
Now lets look at how we would define this same functionality in a Protocol-Oriented way.
Protocol-Oriented Design
Just like with the Object-Oriented design, we will want to start off with a type diagram that
shows the types needed to create and the relationships between them. The following
diagram shows our Protocol-Oriented design.

As we can see our POP design is different from our OOP design. In this design we use
three techniques that make POP significantly different from OOP. These techniques are
protocol inheritance, protocol composition and protocol extensions.
Protocol inheritance is where one protocol can inherit the requirements from one or more
other protocols. In our example the LandAnimal, SeaAnimal and AirAnimal protocols will
inherit the requirements of the Animal protocol.Protocol composition allows types to
conform to more than one protocol. This is one of the many advantages that POP has off
OOP. With OOP a class can have only one superclass which can lead to very monolithic
superclasses as we just saw. With POP we are encouraged to create multiple smaller
protocols with very specific requirements.Protocol extensions are arguably one of the most
important parts of the protocol-oriented programming paradigm. They allow us to add
functionality to all types that conform to a given protocol. Without protocol extensions if
we had common functionality that was needed for all types, that conformed to a particular
protocol, then we would have had to add that functionality to each type. This would lead to
large amounts of duplicate code and that would not be ideal to say the least.
Let's look at how this design works. We will start off by defining our Animal
protocol.Notice that we specify that the Lion type conforms to the LandAnimal protocol
while the Alligator type conforms to both the LandAnimal and SeaAnimal protocols.Having
a single type that conforms to multiple protocols is called protocol composition and is what
allows us to use smaller protocols rather than one giant monolithic superclass as in the OOP
example.
Both the Lion and Alligator types originate from the Animal protocol therefore we can still
use polymorphism as we did in the OOP example where we use the Animal type to store
instances of the Lion and Alligator types. Lets see how this works:
seeing some of the advantages that protocol-oriented programming has over object-oriented
programming, we may think that protocol-oriented programming is clearly superior to
object-oriented programming. Object-oriented programming and protocol-oriented
programming have similar philosophies like creating custom types that model real-world
objects and polymorphism to use a single interface to interact with multiple types. The
difference is how these philosophies are implemented.

To me, the code base in a project that uses protocol-oriented programming is much safer
and easier to read and maintain as compared to a project that uses object-oriented
programming. This does not mean that I am going to stop using object-oriented
programming all together. I can still see plenty of need for class hierarchy and inheritance.

139.What iOS architectures do you know that scale and design patterns are commonly
used in iOS apps, which one better for iOS Development?
Typical commonly used patterns when building iOS applications are those that Apple
advocates in their Cocoa, Cocoa Touch, Objective-C, and Swift documentation. These are
the patterns that every iOS developer learns. Apple refers to them as “core competencies”
design patterns. They include MVC, Singleton, Delegate, and Observer.
When an interviewer asks this question (in one form or another), he is looking for
something besides MVC. Because MVC is the go-to design pattern, the expectation is that
every iOS developer knows it. What they want to hear from you, though, is what else we
commonly use out of the box.
Design patterns are reusable solutions to common problems in software design.
They’re templates designed to help you write code that’s easy to understand and reuse.
They also help you create loosely coupled code so that you can change or replace
components in your code without too much hassle.
The most common Cocoa design patterns:
Creational: Singleton.
Structural: MVC, Decorator, Adapter, Facade.
Behavioural: Observer, and, Memento
How to Use the Memento Pattern:
iOS uses the Memento pattern as part of State Restoration, but essentially it stores and
re-applies your application's state so the user is back where they left things.
Singleton design pattern:
The Singleton design pattern ensures a class only has one instance, and provides a
global point of access to it. The class keeps track of its sole instance and ensures
that no other instance can be created. Singleton classes are appropriate for
situations where it makes sense for a single object to provide access to a global
resource.Several Cocoa framework classes are singletons. They
include NSFileManager, NSWorkspace, NSApplication,UIKit,UIApplication. A
process is limited to one instance of these classes. When a client asks the class for an
instance, it gets a shared instance, which is lazily created upon the first
request.Singleton is a class that returns only one and the same instance no matter
how many times you request it.Singletons are sometimes considered to be an anti-
pattern.
There are multiple disadvantages to using singletons:
The main ones are global state, object life-cycle, and dependency injection. When
you have only one instance of something, it’s very tempting to reference and use it
everywhere directly instead of injecting it into your objects. That leads to
unnecessary coupling of concrete implementation in your code instead of working
with an interface abstraction.
Another malicious side effect of “convenient” singletons is the global state. Often
singletons enable global state sharing and play the role of a “public bag” that every
object uses to store state. That leads to unpredictable results and bugs or crashes

when this uncontrolled state gets overridden or removed by someone.Even though in


some languages and platforms singletons are considered to be good, they are in fact
an anti-pattern that should be avoided at all costs.

Static variable will be deinit when program or app stops working.

1. One of the main disadvantages of singletons is that they make unit testing very hard.
They introduce global state to the application. The problem is that you cannot completely
isolate classes dependent on singletons. When you are trying to test such a class, you
inevitably test the Singleton as well. When unit testing, you want the class to be as loosely
coupled with other classes as possible and all the dependencies of the class should be
ideally provided externally (either by constructor or setters), so they can be easily mocked.
Unfortunately, that is not possible with singletons as they introduce tight coupling and the
class retrieves the instance on its own. But it gets even worse. The global state of stateful
singletons is preserved between test cases.

2. It is static so memory will not be freeze until app will killed. It has it's own creation time
and its own lifecycle.

3. Singletons create hidden dependencies. As the Singleton is readily available throughout


the code base, it can be overused. Moreover, since its reference is not completely
transparent while passing to different methods, it becomes difficult to track. (To solve that
we should pass singleton object variable as parameter and this way is called dependency
injection).
You can create a thread safe singleton using DispatchQueue.
private let serialQueue = DispatchQueue(label: "serialQueue")

serialQueue.sync{
result = dict[key]
}

Decorator design pattern:


In contrast to singleton, this pattern, (alternatively called Wrapper together with the Adaptor
pattern), lets a specific behaviour to be added up to a single object (either statically or
dynamically), and all of this without affecting the behaviour of other objects this one shares
a class with.
The 4 most -commonly used patterns are MVC, MVP, MVVM and VIPER.
MVC pattern:

Module - View - Controller, widely-known as MVC, is one of the first pattern approaches
of the Object - Oriented Programming. The View part is responsible for displaying
everything for system’s user (interfaces of mobile or web app, etc.). Model is generally
responsible for the databases, business entities and rest of data. In its turn, Controller
regulates the Model’s work, data provided to the database, display from the mentioned
database to the View part and vice versa.
The issue Apple’s system has lies in the tight connection between View and Controller
parts, tight almost to the point of having united View & Controller, and leaving Model part
separated. Consequently, it results in poor testing process only Model could be examined,
V&C (due to the tight connection they have) can not be tested at all.The robust connection
between Controller and View segments proved to be truly “unhealthy” when it comes to
software, so a new pattern saw the world soon.
Models: represent application data, any data objects, NSManagedObject subclasses and
similar are models
views: draw things on the screen, UIView subclasses (Cocoa Touch or custom) are views
controllers: manage data flow between model and view, UIViewControllers and their
subclasses are controllers
Massive View Controller is the state of a codebase where a lot of logic and responsibility
was showed into View Controllers that doesn’t belong there. That practice makes your code
rigid, bloated, and hard to change. There are other design patterns that can help you remedy
this, such as MVVM, MVP, and Coordinator. And there are architectures such as VIPER
and RIBs that were made specifically for the purpose of scaling iOS code and avoiding
Massive View Controller problem.
MVP pattern:

The Model View Presenter pattern has few key points, forming a vast gulf between it and
MVC:
MVP Model
• View is more loosely coupled to the model. The Presenter is responsible for binding
the Model to the View.
• Easier to unit test because interaction with the view is through an interface.
• Usually View to Presenter = map one-to-one. Complex views may have multi
presenters.
In this arrangement Model’s functions stay the same.Presenter is responsible for the
business logic respectively. The V part is the one of particular interest as it is divided into
two parts View and View Controller which are in authority for interaction. When there is a
MVVM vs MVC question, the system of this type solves the problem of a “heavy
addiction” View and Controller modes used to have in MVC pattern.
The testing obstacle is also solved in this case, as Model, View with user interaction, and
Presenter parts - all of these could be tested.The yet existing inconvenience is in Presenter’s
part yet way too massive, yet takes into the account all of the existing business logics.
Which is why the next act came into play, named…
MVVM pattern:

A Model-View-ViewModel software architectural pattern has been created in 2005 by John


Gassman, one of Microsoft’s architects. The three core components of MVVM model
respectively are:
Model: is “an implementation of the application's domain model that includes a data model
along with business and validation logic. Examples of model objects include repositories,
business objects, data transfer objects (DTOs), Plain Old CLR Objects (POCOs), and
generated entity and proxy objects.” [Source: Microsoft]






View: is again everything that user is capable of seeing - the layout, the structure and the
appearance of everything on the screen. Basically, within the application it would be app’s
page. View gets and sends updates to ViewModel only, excluding all the communication
between this part and Model itself.
ViewModel: is supposed to be an “interconnecting chain” between the View and Model
system components, and it’s main function is to handle the View’s logic. Typically, the view
model interacts with the model by invoking methods in the model classes. The view model
then provides data from the model in a form that the view can easily use, as Microsoft
states.
The main difference between MVC and MVVM is that MVVM’s distribution pattern is
better than in the previously-listed MVC, but when compared to MVP it is also massively
overloaded. Testing is a matter of particular importance here, as while plainly writing the
code you can not guarantee that the whole project will function properly tests, on the bright
note, help to ensure it will.
The next architectural patterns’ evolution has been recently released and is now the freshest
software architectural approach.
iOS VIPER architecture:

Clean Architecture splits the application’s logical structure into several responsibility levels.
In it’s turn, this “separation” resolves the tight dependency issues and increases the testing
availability of all levels.
As a common rule for all the patterns’ names, it is a backronym as well, for View,
Interactor, Presenter, Entity and Routing. Each of the VIPER’s parts is responsible for a
certain element, particularly:
View: is responsible for mirroring the actions user makes with an interface
Presenter: responsibilities within the VIPER pattern are quite limited - it receives the
updates from Entity, but doesn’t send any data to it;
Interactor: is the system’s part that actually corresponds with Entities. This scheme works
in the following direction: Presenter informs Interactor about the changes in the View
model, then Interactor contacts the Entity part, and, with the data received from Entity
Interactor gets back to Presenter, which commands View to mirror it for a user. All the data
models, all the entities and all the websites are connected to the Interactor part.
Entity: consists out of objects that are controlled by Interactor (titles, content. etc.)It never
interacts with Presenter directly, only via I-part.
Routing: (or Wireframe as it is sometimes called) is responsible for navigation between all
of the screens, and, essentially, for routing. Wireframe controls the objects of UIWindow,
UINavigationController and so on. Particularly within iOS architectural system it is all built

upon a framework called UIkit, which includes all the components of Apple MVC, but
without a tight connection that used to drive coders mad before.
VIPER module is as well beneficial once it comes to unit tests, as the great pattern’s
distribution lets you test all the functional available. In many ways this was the main
difficulty developers faced with previous MVC, MVP and MVVM software patterns.
All of these 4 software design patterns are often called one of the best architecture Patterns
for iOS development, even though all of them are less than ideal and definitely not
universally used for each and every project you get to develop. On the gloomy side, here is
a short list of issues each pattern has:
• MVC, MVP, MVVM - all of them have this “tight connection” issue, which makes
introducing updates to development, and testing them afterwards quite a harsh task
to accomplish.
• VIPER vs MVVM, MVC or MVP, is thought to be a winning case; although despite
its high flexibility and great testability also has many nuances that are hard to
generate.

140.New Build System in Xcode?


The new build system from Apple is designed to improve the performance, stability and
reliability of the Swift build. It will catch the configuration errors early in the application
development. It’s been activated by default in Xcode 10 so sooner or later we have to
update our build process to adapt to the new build system. Surely, it will bring a lot of
configuration enhancement in the app.

141.What’s new in Swift 5.4


Swift 5.4 brings with it some huge compilation improvements, including better code
completion in expressions with errors and big speed ups for incremental compilation.
However, it also adds some important new features and refinements, so let’s dig into them
here…
Improved implicit member syntax
SE-0287 improves Swift’s ability to use implicit member expressions, so rather than just
having support for exactly one single static member you can make chains of them.
Swift has always had the ability to use implicit member syntax for simple expressions, for
example if you wanted to color some text in SwiftUI you could use .red rather than
Color.red:
Multiple variadic parameters in functions
SE-0284 introduced the ability to have functions, subscripts, and initializers use multiple
variadic parameters as long as all parameters that follow a variadic parameter have labels.
Before Swift 5.4, you could only have one variadic parameter in this situation.
So, with this improvement in place we could write a function that accepts a variadic
parameter storing the times goals were scored during a football match, plus a second
variadic parameter scoring the names of players who scored:
Creating variables that call a function of the same name
From Swift 5.4 onwards it’s possible to create a local variable by calling a function of the
same name. That might sound obscure, but it’s actually a problem we hit all the time.
For example, this creates a struct with a color(forRow:) method, which gets called and
assigned to a local variable called color:
Result builders




Function builders unofficially arrived in Swift 5.1, but in the run up to Swift 5.4 they
formally went through the Swift Evolution proposal process as SE-0289 in order to be
discussed and refined. As part of that process they were renamed to result builders to better
reflect their actual purpose, and even acquired some new functionality.
First up, the most important part: result builders allow us to create a new value step by step
by passing in a sequence of our choosing. They power large parts of SwiftUI’s view
creation system, so that when we have a VStack with a variety of views inside, Swift
silently groups them together into an internal TupleView type so that they can be stored as a
single child of the VStack – it turns a sequence of views into a single view.
Result builders deserve their own detailed article, but I at least want to give you some small
code examples so you can see them in action.
Local functions now support overloading
SR-10069 requested the ability to overload functions in local contexts, which in practice
means nested functions can now be overloaded so that Swift chooses which one to run
based on the types that are used.
Property wrappers are now supported for local variables
Property wrappers were first introduced in Swift 5.1 as a way of attaching extra
functionality to properties in an easy, reusable way, but in Swift 5.4 their behavior got
extended to support using them as local variables in functions.
Packages can now declare executable targets
SE-0294 adds a new target option for apps using Swift Package manager, allowing us to
explicitly declare an executable target.
This is particularly important for folks who want to use SE-0281 (using @main to mark
your program’s entry point), because it didn’t play nicely with Swift Package Manager – it
would always look for a main.swift file.
With this change, we can now remove main.swift and use @main instead. Note: You must
specify // swift-tools-version:5.4 in your Package.swift file in order to get this new
functionality.

142.Mobile Device Management (MDM) in iOS?


The Mobile Device Management (MDM) protocol provides a way for system
administrators to send device management commands to managed iOS devices running iOS
4 and later, macOS devices running macOS v10.7 and later, and Apple TV devices running
iOS 7 (Apple TV software 6.0) and later. MDM allows for OS level control of multiple
devices from a centralised location. A remote administrator can install/remove apps, install/
revoke certificates, lock the device, change password requirements, etc.

143.Which is testing framework is best?


This really depends on which day you ask me that. I’ve been working with Expecta on
XCTest recently, and I like that combination, but there are things that the other frameworks
appear to do better. Here’s a comparison of some key features:
FRAMEWO XCODE RUNS DEBUGGI
NOTES
RK INTEGRATION ON: NG
XCTest Best Both Good Built-into Xcode 5

OCUnit Best Simulator Good Built-into Xcode


GHUnit Add-on Both Good Separate build target

Matchers, supports
Expecta Good Both Good
async

OCHamcre
Good Simulator Good Matchers
st

Kiwi Good Simulator Difficult? Blocks run on OCUnit


Note that GHUnit runs as a separate build target. This allows running unit tests stand-alone
on either a device or simulator. This is fabulous for things like API tests. Not quite so
convenient for Continuous Integration tests.
Apple often breaks OCUnit or its templates when a new version of Xcode is
released. Caveat Emptor.

144.How much test coverage is enough?


As much as you can. Programmer’s often panic when asked to provide 100%, so instead I
just say “test everything”.

145.Should I unit test views and/or view controllers?


You should test every line of code that you write. If you are inheriting legacy code, then add
tests for every line of code that you plan to modify. Note: Michael Feathers defines legacy
code as code that doesn’t contain tests. I agree.

146.Doesn’t adding unit tests take more time?


That depends on which times you are comparing. If you compare the sum of the times spent
writing the code, debugging the code, and later on extending the code, then unit tests should
be the hands-down winner. If you are only comparing the time spent writing the code, then
clearly it takes less time to write buggy, unmaintainable code that might not work correctly.

147.setUp() And tearDown() in XCTest?

• setUp() — This method is called before the invocation of each test method in
the given class.
• tearDown() — This method is called after the invocation of each test method
in given class.
You can customise setUp()and teardown() in 5 different ways,
1. Override setUp() class method to setup initial state for all test methods.
2. Override setUp() instance method to reset initial state before each test method is
executed.
3. You can have self-contained blocks of teardown code with the addTearDownBlock(_:)
method during a test method’s execution.
4. Override tearDown() instance method to clean after each test method executes.
5. Override tearDown() class method to clean after all test methods execute.

148.Designated Initialisers and Convenience Initialisers?




Convenience initialisers are used when you have some class with a lot of properties that
makes it kind of "Painful" to always initialise wit with all that variables, so what you do
with convenience initialiser is that you just pass some of the variables to initialise the
object, and assign the rest with a default value.Here is an example where you can see that
instead of initialising my object with all those variables Im just giving it a title.
struct Scene {
var minutes = 0
}

class Movie {
var title: String
var author: String
var date: Int
var scenes: [Scene]

init(title: String, author: String, date: Int) {


self.title = title
self.author = author
self.date = date
scenes = [Scene]()
}

convenience init(title:String) {
self.init(title:title, author: "Unknown", date:2016)
}

func addPage(page: Scene) {


scenes.append(page)
}
}

var myMovie = Movie(title: "my title") // Using convenience initialiser


var otherMovie = Movie(title: "My Title", author: "My Author", date: 12) // Using a long
normal initialiser

149.Local, Global and Static variables?

• scope, which determines where a name can be accessed - global and local
• storage duration, which determines when a variable is created and destroyed - static
and auto
Local: The variables which are declared inside the function, compound statement (or block)
are called Local variables.
Global: The variables declared outside any function are called global variables. They are
not limited to any function. Any function can access and modify global variables. Global
variables are automatically initialised to 0 at the time of declaration.

Static: A Static variable is able to retain its value between different function calls. The static
variable is only initialised once, if it is not initialised, then it is automatically initialised to
0. Here is how to declare a static variable, Static variables have a lifetime that lasts until the
end of the program. If they are local variables, then their value persists when execution
leaves their scope.
Auto: Automatic variables are local variables whose lifetime ends when execution leaves
their scope, and are recreated when the scope is reentered.

150.Which Inheritance will supports in Swift Single, Multiple or Multilevel?


Swift supports single inheritance, we can approach multiple inheritance using protocols and
multilevel inheritance it won’t support in Swift.
Single: a class is allowed to inherit from only one class. i.e. one sub class is inherited by
one base class only.
Multiple: When a derived class is derived from more than one base class, it is known as
multiple inheritance.
Multilevel: When one class inherits the properties of another class, which is further
inherited by another class, it is known as multilevel inheritance.

151.Debugging skills in iOS


• Breakpoints
• LLDB(pop, p, v)
• Devices’s Container
• Network Link Conditioner
• Identifying the issues which occur only on device(and not in debug mode)
• View Hierarchy

152.What difference between 'self' and ‘Self'?


When you’re writing protocols and protocol extensions, there’s a difference between Self
(capital S) and self (lowercase S). When used with a capital S, Self refers to the type that
conform to the protocol, e.g. String or Int. When used with a lowercase S, self refers to the
value inside that type, e.g. “hello Swift” or 786.

153.What’s the difference between == and ===?


Swift gives us two equality operators, == and ===, that do slightly different things. You will
almost certainly need to use both of them so it’s worth taking the time to learn them.
First, == is the equality operator, which tests that two things are equal for whatever
definition of “equal” those things use. For example, 5 == 5 is true because there == means
an integer comparison, and the same is true for other built-in value types such as strings,
booleans, and doubles.
Things get more complicated when == is used with a struct you built, because by default
they cannot be compared – you need to make them conform to the Equatable protocol.
In comparison, === is the identity operator, which checks whether two instances of a class
point to the same memory. This is different from equality, because two objects that were
created independently using the same values will be considered equal using == but not ===
because they are different objects.
The === operator is available only when using classes because structs are designed so they
are always uniquely referenced.

154.Write a Palindrome program


func isPalindrome(_ value: String) -> Bool
{
let len = value.count / 2

for i in 0..<len
{
let start = value.index(value.startIndex, offsetBy: i)
let end = value.index(value.endIndex, offsetBy: (i * -1) - 1)

if value[start] != value[end] {
return false
}
}

return true
}

print(isPalindrome("sass"))

155.What is QualityOfService in operation?


Used to indicate the nature and importance of work to the system. Work with higher quality
of service classes receive more resources than work with lower quality of service classes
whenever there is resource contention

● This property specifies the service level applied to operation objects added to the

queue ● If the operation object has an explicit service level set, that value is used instead.

The default value of this property depends on how you created the queue. For queues you
create yourself, the default value is NSOperationQualityOfServiceBackground. For the
queue returned by the main method, the default value is
NSOperationQualityOfServiceUserInteractive and cannot be changed.

https://www.allaboutswift.com/dev/2016/5/21/gcd-with-qos-in-swift

Types of QualityOfService ● User Interactive All UI related tasks need to be assigned that
QoS class. It basically tells iOS to run them on the main thread.

● User Initiated This is the class to choose if a task is triggered by the user but doesn't have
to be run necessarily on the main thread.

● Default This class is only listed for informational purposes only. The system defaults to
this class when not enough information is available to determine QoS.

● Utility This class needs to be chosen for tasks that have a dependency on other system
resources like file I/O or network I/O. Those tasks need to wait for a certain amount of time
before they are able to complete. They are always in one way or another initiated by the
user who waits for their completion.

● Background This class is supposed to be used for maintenance tasks - Tasks that don't
depend on their fast execution and that are oblivious to the user.

● Grand Central dispatch (Multi threading concept) GCD is a library that provides a low-
level and object-based API to run tasks concurrently while managing threads behind the
scenes. Terminology

● Dispatch Queues:- A dispatch queue is responsible for executing a task in the first-in,
first-out order

● Serial Dispatch Queue :- A serial dispatch queue runs tasks one at a time.

● Concurrent Dispatch Queue:- A concurrent dispatch queue runs as many tasks as it can
without waiting for the started tasks to finish.

● Main Dispatch Queue:- A globally available serial queue that executes tasks on the
application’s main thread.

156.Write a String reverse program


func poly()
{
let name:String="sandeep"
var polyname=""
for name1 in name
{
polyname=String(name1)+polyname

}
print(polyname)
}

poly()

157.When would you use Swift’s Result type?


The Swift Result Type
Apple added the Result type to the Swift Standard Library in Swift 5. It’s an enum with a
success and failure case both of which have an associated value. You can use any type for
Success but Failure is constrained to Error:
enum Result<Success, Failure> where Failure : Error {
case success(Success)
case failure(Failure)
}

158.What is a UUID, and when might you use it?


Suggested approach: UUID stands for "universally unique identifier", which is a long string
of hexadecimal numbers stored in a single type.
UUIDs are helpful for ensuring some value is guaranteed to be unique, for example you
might need a unique filename when saving something.
For bonus points, perhaps explain why we call them universally unique – if you created 100
trillion UUIDs there's a one in a billion chance of generating a duplicate.

159.What is the difference between the Float, Double, and CGFloat data types?
Suggested approach: It’s a question of how many bits are used to store data: Float is always
32-bit, Double is always 64-bit, and CGFloat is either 32-bit or 64-bit depending on the
device it runs on, but realistically it’s just 64-bit all the time.
For bonus points, talk about how Swift 5.5 and onwards allows us to use CGFloat and
Double interchangeably.

160.Types of ranges?
There are multiple types of ranges in Swift you can use. The easiest way of working with
them is by making use of the range operator. Let’s go over the different types available in
Swift.

Closed range operator going from a…b


A closed range operator going from a...b defines a range that includes both a and b in which
a must not be greater than b.
The closed operator is useful if you’d like to use all the values.

Half-open range operator going from a..<b


A half-open range defines a range going from a to b but does not include b. It’s named half-
open as it’s containing its first value but not its final value. Just like with the closed range,
the value of a must not be greater than b.
The half-open operator can be used to iterate over zero-based lists such as arrays and
collections in Swift in which you want to iterate up to but not including the length of the
list.

One-sided operator going from a…


A one-sided range operator only defines one side of the bounds, for example, a... or ...b. A
one-sided range goes as far as possible in one direction
A one-sided range can be used for iteration but only if used with a starting value a....
Otherwise, it’s unclear where the iteration should start. Iterating over a one-sided range
requires you to manually check where the loop should end as it would otherwise continue
indefinitely.

161.How would you explain Dynamic Type to a new iOS developer?


Suggested approach: This is a sneaky question, because if you say “I don’t use it” or
(worse) “I don’t know what it is”, it sort of means you don’t pay attention to accessibility or
user preferences. Dynamic Type is a way of allowing the user to adjust their preferred size

for all fonts in all apps, and it's surprisingly easy to use from both a developer and user
perspective. SwiftUI even defaults to using it across the board!

162.What is apple developer/enterprise account??


We can Create two types of Apple account
1.Developer $99
2.Enterprise $299

Developer account We can create Two types of certificate


A.Development
B.Production

A. Development
--It’s use to test app internally

B.Production
--It’s use to upload app on app store

Profiles
There are two types of Profile
1.Development
2.Distribution

1.Development Use this profile for team (internal development purpose)


2.Distribution It’s use to upload app on app store

163.Difference between network location and gps location?


Network location usually refers to cellular location, or wifi location. They are less accurate
then GPS (Global Positioning System - satellite based) location. When the app cannot
obtain GPS location (probably because the target device is inside a building), the less
accurate network location is obtained and uploaded to the map page.

164.I have written for loop from 1 to 10. But when i=7 then then it comes out from
loop. I have not written any specific keyword nor exception generated. How it is
possible?
for(int i=0, i<10:i++)
{
if(i==6)
{
i=10;
}
}
Here I am trying to iterate from 0 to 9. This loop is iterating till Condition i<10 matches.
Now in iterating, when loop comes i=6 I will make i=10.
So in next iteration, i<10 condition is mismatched. So it comes out from loop.
There is no any keyword used or any exception generated.

165.Difference between FCM and APNS?

• FCM is sent as JSON payloads and APNS sends either string or dictionary.
• FCM has a payload of 2KB while APNS has a payload of 4KB.
• VOIP notification - 5KB
• APNS saves 1 notification per App while FCM saves 100 notifications per device.
• FCM supports multiple platforms while APNS requires their proprietary platform.
• Acknowledgment can be sent in FCM if using XMPP, but it's not possible on APNS.
Advantage of FCM:
• Even if the user disallows notification, you can notify your app if the app is running
in the foreground (using shouldEstablishDirectChannel).
• Don't need to create dashboard to send notification on the device.
• Notification analytics on FCM Dashboard.
• Easy to create notification payload structure.
• App Server side handling is easy, Only one key is required for multiple apps and
platform (iOS, Android, Web)

166.Determine index of one integer in another integer - online programming question?

Problem Description : Determine index of one integer in another integer

i.e If input A = 23,B = 1472367 then Output : 3 . Because '23' is 3rd index in ‘1472367'.

int solution(int A, int B) {


// write your code in Objective-C 2.0
NSString *strA = [NSString stringWithFormat:@"%d",A];
NSString *strB = [NSString stringWithFormat:@"%d",B];

NSRange range = [strB rangeOfString:strA];


if(range.location == NSNotFound)
return -1;
else
return range.location;
}

167.Write a program to find missing number of array of 1 to n?


let arr = [1,2,4,5,8,6,9,7]
let n = arr.count
let total = ((n + 1)*(n + 2))/2
var missingNum = total
for item in arr {
missingNum = missingNum - item
}
print(missingNum)

168.Write a program to distinguish lowercase and uppercase character from String in


swift?

let string = "iOSiQA is Very Helpful WebSite to Prepare for iOS Interview."
var output = ""

for chr in string {


var str = String(chr)
if str.lowercaseString != str {
output += str
}
}
print(output)

169.Can we make a class-specific protocol?


You can limit protocol adoption to class types (and not structures or enumerations) by
adding the AnyObject or class protocol to a protocol’s inheritance list.

protocol someprotocol : AnyObject, Someanotherprotocol {

170.Can we declare an optional protocol method in swift?


Yes. In that protocol name and optional methods should be followed by @objc due to it
consider as objective c code.

@objc protocol someprotocol {


@objc optional func somemethod()
@objc optional var someName : String { get set }
}

or

We can make protocol extension and provide default body to protocol method. So any class
or struct confirms that protocol doesn't require implementing that method.

171.Can we define property in extension?


Swift doesn’t support stored properties inside the extension. Computed property is allowed
in extension.

172.Can we define property in protocol?


Property in protocol must have explicit { get } or { get set } specifier.

protocol VoiceAssistant {
var s : String // Not allowed
var name: String {get} // Allowed
var voice: String {get set} // Allowed

173.How we stop notification to be sent to device who is uninstalled?


The push message service has a feedback channel which reports error messages when the
application has been removed or the device no longer accepts the push messages.

"The Apple Push Notification service includes a feedback service to give you information
about failed remote notifications. When a remote notification cannot be delivered because
the intended app does not exist on the device, the feedback service adds that device’s token
to its list. Remote notifications that expire before being delivered are not considered a failed
delivery and don’t impact the feedback service. By using this information to stop sending
remote notifications that will fail to be delivered, you reduce unnecessary message
overhead and improve overall system performance.”

174.What is p12 and pem file?


p12 : .p12 is an alternate extension for what is generally referred to as a "PFX file", it's the
combined format that holds the private key and certificate and is the format most modern
signing utilities use. Same with alternate extensions are .PFX, .PKCS12

pem : this is a container format that may include just the public certificate (such as with
Apache installs, and CA certificate files /etc/ssl/certs), or may include an entire certificate
chain including public key, private key, and root certificates.

Convert from .p12 file to .pem file

cdcd Desktop openssl pkcs12 -in pushcert.p12 -out pushcert.pem -nodes -clcerts

175.What are join in sql? Explain Types of Join?


Join : When we need data from more than 1 table, then we can fetch data from those table
using joining those table. It will return only matching data from two tables.

Select * from table1 t1 inner join table2 t2 on t1.column1 = t2.column1

Types of Join :

1. Inner Join : If we use inner join between two table, then only data exists in both table, are
returned.

2. Outer Join :
Left Outer Join : It returns all data from left table(table1) and only matching data from
both table.
Right Outer Join : It returns all data from right table(table2) and only matching data from
both table.

3. Cross Join : It is like cartesian join. It returns all records from both table and it returns
table1.count * table2.count records in returns. Suppose table1 has 4 records and table2 has
3 records and returns 4*3 records.

4. Self Join : If some column's reference has in same table then self join is used. It is same
like inner join but here both left and right table are same. Its like if you table and Columns
are such as MainID, Name, ParentID then you can make query like
Select * from table t1 join table t2 on t1.MainID = t2.ParentID

176.Add column in SQLite?


If we have uploaded our app ver 1.0 and we want to add columns in sqlite database, then
following thing can done.

If we have sqlite database which table structure can be changed after release. Then we need
to maintain database version. We can update database version by excecuting query like
PRAGMA user_version = version_num; (For swift : PRAGMA table_info(tblTest))

In second release If we need to add columns, then we can check database version, If
database version is old version then we can execute following query :

ALTER TABLE {tableName} ADD COLUMN COLNew {type};

177.If there are two views up and bottom, up-view is 60% of superview and 40% of
superview respectively, then what to do with constraint?

We took 2 views - Orange and Green.


We set orange view's top, leading, trailing constraint to main view as 0.
Same, we set green view's bottom, leading, trailing constraint to main views as 0.

Now,

We select height constraint of orange view equal to main view's height. And set multiplier
0.6. It shows ratio of orange view's height to main view's height. We have set 0.6 = 60/100 .
So orange view's height become 60% of main view's height.
Same we have done with green view and set multiplier 0.4 = 40/100 means 40%.

178.What is Content Hugging and Content


Compression Resistance Priority?
The priority really come in to play only if two different
constraints conflict. The system will give importance to the
one with higher priority. So, Priority is the tie-breaker in the
autolayout world.

1. Content Hugging Priority :

Larger the content hugging priority , the views bound


will hug to the intrinsic content more tightly preventing the
view to grow beyond its intrinsic content size. Setting a
larger value to this priority indicates that we don’t
want the view to grow larger than its content.

In above example, we set both label leading, trailing, top and bottom but not set width
constraint. So here conflicts will occur. You can see red line between two label showing
conflict.

Solution : If we have label's content hugging priority higher than there will be no conflicts
as hight priority label will not grow its size more than its content size. See below image :

Blue label has more content hugging priority (251) than green label(250). Blue label's width
will be set fixed as its content size.

2. Content Compression Resistance :

Setting a higher value means that we don’t want the view to shrink smaller than the intrinsic
content size. It's simple : Higher the priority means larger the resistance to get shrunk.

Example . One button having large name and auto layout is set on button as its width is
become 40. So, button's content is not readable. See image :

Button horizontal compression resistance is 750 and width constraint priority is 1000.
For Solution, let's change horizontal compression resistance to 1000 and width constraint
priority less than 1000 i.e 999 . Now see effect on below image :

Button horizontal compression resistance is 1000 and width constraint priority is 999.

179.What method is called after tap back button in ios?


When you go back the following methods will be called:

Notifies the view controller that its view is about to be added to a view hierarchy :

override func viewWillAppear(_ animated: Bool) {


super.viewWillAppear(animated)
}

Notifies the view controller that its view was added to a view hierarchy :

override func viewDidAppear(_ animated: Bool) {


super.viewDidAppear(animated)

180.What is StackView? What is advantage and distribution type of stackview?


Stack View allows to layout views in a stack in either horizontal or vertical fashion. In
Xcode-7, stackview is introduced.

Advantage : Stacks are containers that keep views aligned automatically.

Distribution Types :

Fill(Default) : When you place your controls inside a UIStackView with Fill set as the
distribution, it will keep all but one of the controls at their natural size and stretch one of
them to fill the space. It determines which control to stretch by noting which one has the
lowest Content Hugging Priority (CHP).

Fill Equally : With this type, each control in a UIStackView will be of equal size. All of the
space between the controls will be used up, if possible. I added a spacing of eight between
the UITextFields, so again you could see the size of each one. With this type, the CHP does
not matter, because each control is the same size.

Fill Proportionally : The UIStackView will ensure the controls maintain the same
proportion relative to one another as your layout grows and shrinks. Unlike the previous
two settings, the Fill Proportionally distribution needs the controls to have an intrinsic
content size. The Fill and Fill Equally distribution tell their child controls how big they
should be, but this one is the other way around (as long as there is enough space for all of
your controls to be their natural size). The proportions for the images and labels are
maintained for the different layout sizes.

Equal Spacing : This distribution type will maintain an equal spacing between each of the
controls and will not resize the controls themselves.

Equal Centring : It will equally space the centres of the controls. Space between every
control is equal.

181.Enlist different background modes?


There are different background modes provided from apple and we can see them under
Signing & Capabilities > + Capability (New) > Background Mode
Switch on background mode and select which is required in our project.

1. Audio, AirPlay and Picture in Picture


2. Location updates
3. Void over IP
4. External accessory communication
5. Uses Bluetooth LE accessories

6. Acts as a Bluetooth LE accessory


7. Background fetch
8. Remote notifications
9. Background processing

182.How does CloudKit differ from Core Data?


Suggested approach: Although the two have many conceptual similarities, CloudKit is
specifically designed to work remotely. Another key difference is that CloudKit lets you
store data without worrying about your structure ahead of time, whereas Core Data requires
that you define your structure up front.

183.What are the different ways of showing web content to users?


Suggested approach: You don’t need to have named them all, but it certainly helps:
UIWebView, WKWebView, SFSafariViewController, and calling openURL() on
UIApplication. Don’t just list them off, though: at least mention that UIWebView is
deprecated, but if you can you should also compare and contrast WKWebView and
SFSafariViewController.

184.How much experience do you have using iBeacons? Can you give examples?
Suggested approach: iBeacons were introduced way back in iOS 7, and have found mixed
use – unless you’re applying for an iBeacon development job this is one you can probably
skip with “I haven’t used them much, but I’m keen to learn!”
Of course, if you do have experience then this is your time to shine: talk about major and
minor identifiers, talk about positioning beacons overhead to avoid interference from
people and devices, talk about ranging, and more.

185.What are the advantages and disadvantages of SwiftUI compared to UIKit?


Suggested approach: Try to be thoughtful here – coming down hard on one side rather than
the other isn’t a good look, so instead try to think about what each framework does well and
less well.
For example, UIKit gives us endless customizability, for example, as well as access to
almost the full range of iOS UI tools, but takes a lot more code to use and you need to
handle all the state changes properly. On the other hand, SwiftUI gives us access to fewer
iOS components, but takes less than a fifth of the amount of code to write and does a huge
amount of extra work for us.

186.Can you talk me through some interesting code you wrote recently?
Suggested approach: Hopefully you can go straight to GitHub and pick an interesting
project. If not, why not? Your projects don't need to be amazing, clever, or even popular, but
if you literally have nothing to show you’re going to have a much harder job convincing
companies to hire you.

187.Do you have any favorite Swift newsletters or websites you read often?
Suggested approach: Most employers will say it's important to be able to demonstrate that
you’re committed to learning more about your craft. I subscribe to iOS Dev Weekly, Swift
Weekly Brief, and This Week in Swift – all are interesting. Obviously I would hope you
mention Hacking with Swift too, but I'm biased!

188.How do you stay up to date with changes in Swift?


Suggested approach: We develop in a fast-changing world, not least because Apple bump
all their major versions every year. Be prepared to talk about books you read, sites you visit,
newsletters you subscribe to, conferences you attend, and more – the more specific the
better, because it shows you’re working hard to stay updated.

189.If you could have Apple add or improve one API, what would it be?
Suggested approach: This is a personal choice, and is asked to see how creative or
interesting your answer is. If it were me, I’d love to see either a handwriting detection API
so that we could add handwriting support everywhere, or a weather API so that apps could
integrate weather information in all sorts of places – imagine having a calendar app with
weather forecasts built right in!

190.What books would you recommend to someone who wants to learn Swift?
Suggested approach: Obviously I’d recommend the complete Hacking with Swift series, but
the point is that it gives you a chance to talk about how you learned Swift. You can always
list Apple’s official Swift guide if you’re desperate. Note: Saying "I didn't use any books, I
just worked hard" is a valid answer, but you should at least be aware that such an approach
doesn't work for many people.

191.What open source projects have you contributed to?


Suggested approach: This isn’t a requirement – far from it! – but again shows an eagerness
to learn and an ability to participate. Don’t be afraid to list your own projects if they are
public on GitHub.
For bonus points, being able to say you've contributed to Swift itself is always likely to
make the interviewer impressed, at least a little!

192.Have you ever filed bugs with Apple? Can you walk me through some?
Suggested approach: This is about demonstrating you’re a good citizen of the iOS
community: you file bugs with Apple when you find them, and (just as important!) they are
useful bugs with details and ideally a test case. If you file these properly, walking through
shouldn’t be hard. Keep in mind that if you file bad bugs with Apple it suggests you'd be
pretty bad at filing internal bugs for your own company too.

193.What experience do you have working on macOS, tvOS, and watchOS?


Suggested approach: Keep in mind that many company have significant investments in
Apple computers – being able to make macOS apps for internal use can be a real boost. I
would also suggest that saying you've dabbled in something like watchOS demonstrates
curiosity and an ability innovate. If you’ve moved apps to the Mac using something like
Catalyst that’s also worth discussing here, particularly if you’re able to compare it to
SwiftUI.
First, tvOS provides no browser support of any kind, nor is there any WebKit or other web-
based rendering engine you can program against. This means your app can’t link out to a
web browser for anything, including web links, OAuth, or social media sites.

Second, tvOS apps cannot explicitly use local storage. At product launch, the devices ship
with either 32 GB or 64 GB of hard drive space, but apps are not permitted to write directly
to the onboard storage.
tvOS app bundle cannot exceed 4 GB.

194.What is the purpose of code signing in Xcode?


Suggested approach: I know code signing gets a lot of flak from developers because it can
be quite annoying, but try to think about this from Apple’s perspective, in terms of verifying
a developer is who they say they are, and also how provisioning profiles enable
functionality.
Once you're there, I would connect it to the importance of tight security on the App Store,
because verifying developer identities is one of several steps towards shipping safe apps.

195.What steps do you take to identify and resolve battery life issues?
Suggested approach: This is something so many developers don’t ever think about, so use
this as your chance to shine: talk about optimizing drawing, batching network requests, and
minimizing work when the user isn’t interacting with the app.
Keep in mind that the battery settings app on iOS automatically shows which apps use the
most battery life for a user, so having poor battery performance is very visible.

196.What steps do you take to identify and resolve a memory leak?


Suggested approach: Hopefully you have at least some experience with Instruments, so talk
about persistent vs transient objects, talk about filtering for your custom data types, and so
on. You should also discuss how you can be sure the leak is gone, for example if you push
and pop the same view controller 10 times does the memory level remain constant?

197.What steps do you take to identify and resolve performance issues?


Suggested approach: This is a tricky question to answer because “performance” has many
forms, so be prepared to adjust your answer as you talk based on interviewer feedback.
If they mean graphical performance then you should probably talk about using the Core
Animation instrument to identify slow drawing, but you should also consider venturing into
the cost of Auto Layout in things like table view cells where lots of work happens quickly.
If they mean code performance then perhaps talk about stack traces, retain cycles,
unnecessary caches, and similar – again make sure and bring Instruments in.
And then there's network performance, where you might talk about things such as batching
requests to reduce battery wastage or using compression to save bandwidth.

198.How much experience do you have using Face ID or Touch ID? Can you give
examples?
Suggested approach: If you’re applying for a job at any company that has secure user data,
biometric authentication is almost certainly involved somewhere. Fortunately, it’s not hard
to learn!
For bonus points mention the need for a password backup in case Face ID/Touch ID fails,
but if you're generally stuck here a good approach might be just to say "I haven't used it
before, but I have used the keychain for secure storage."

199.How would you explain App Transport Security to a new iOS developer?

Suggested approach: This is your chance to demonstrate your security knowledge: why is
HTTPS so important, and in what specific cases might you need to opt out? It also an
opportunity to demonstrate your awareness of Apple's app review guidelines, which require
secure transmission of user data.

200.How would you calculate the secure hash value for some data?
Suggested approach: Secure hash values use something like SHA-3, which is not the kind
of code you'd want to write yourself. Instead, the best approach here is to mention
something like Apple's CryptoKit framework, which can do hashing and encryption
quickly, efficiently, and correctly.

201.In which situations do Swift functions not need a return keyword?


Suggested approach: There are three: when the function isn’t supposed to return a value,
when it is supposed to return a value but you’ve used something like fatalError() to skip
that requirement, and when it returns a value using a single expression. That second case is
useful when you have placeholder functions you haven’t implemented yet, or have created
an abstract class where child classes will override your erroring implementations.

202.Apart from the built-in ones, can you give an example of property wrappers?
Suggested approach: If it weren’t for the built-in restriction, this would be easy to answer
with @State, @EnvironmentObject, and more, but with that restriction in place you need to
be more creative – what real example can you think of? For example, a wrapper to make
sure numbers are never negative, or strings are never empty, or perhaps arrays that silently
stay sorted.

203.Can you give useful examples of enum associated values?


Suggested approach: Enum associated values let us attach one or more extra pieces of data
to enum cases – that much is easy enough. However, the key word here is “useful”, which
means you need to provide an example that is even vaguely real world.
For instance, you might describe a weather enum that lists sunny, windy, and rainy as cases,
but has an associated value for cloudy so that you can store the cloud coverage. Or you
might describe types of houses, with the number of bedrooms being an associated integer.
It doesn't really matter what example you choose, because the point is to show you
understand why they are useful outside of a textbook!

204.What are opaque return types?


Suggested approach: Whenever you see some in a return type, it’s an opaque return type –
when you want to specify that some kind of type will be returned, but you don’t want to say
what.
It’s important that you try to explain the difference between an opaque return type and
returning a protocol, because in the latter your returned value can be absolutely anything
whereas in the former the compiler knows what data was actually returned even if you don’t
get access to that.
For bonus points, talk about how SwiftUI uses @ViewBuilder to silently allow us to return
different view types from a view body.

205.How would you explain SwiftUI’s environment to a new developer?

Suggested approach: I would suggest you start off nice and broad, and say that the
environment acts a bit like a singleton manager – you place objects in there and share them
in many places. But then you want to dive into the details a little more, perhaps saying that
actually you can subdivide the environment if you want, allowing some views to have
different environment objects.
I would recommend you try to mention how the environment differs from just injecting an
ObservableObject instance in an initializer.

206.What does the @Published property wrapper do?


Suggested approach: As with many questions, the best answer here starts with a simple
definition (when used inside an ObservableObject an @Published property will
automatically send out change notifications when its value changes), then diving into a
practical example. So, you might say that a class you’re using in SwiftUI has an array of
todo list items, and when that array changes the UI should update – a simple, real-world use
for @Published.

207.When would you use @StateObject versus @ObservedObject?


Suggested approach: Remember to start with a basic definition first, then provide a practical
example. Here, that means saying the @State allows us to mutate a value that belongs to a
struct without using mutating methods. When it comes to a practical example, almost any
kind of value-type SwiftUI binding is good, such as storing text in a TextField.
Suggested approach: I would recommend you start by making the similarities and
differences clear, then sum up by answering the question directly. So, you would say that
both of these property wrappers monitor an observable object for changes, and refresh
SwiftUI views when changes happen. However, @StateObject is used when you create an
object for the first time and want to retain ownership of it, whereas @ObservableObject is
used in other places where you pass the object and does not retain ownership.

208.What's the difference between a view's initializer and onAppear()?


Suggested approach: Using init() and onAppear() both let us run some code early in a
view's lifecycle, however it's important to understand the difference between them.
SwiftUI creates all its view structs immediately, even creating destination views for
navigation links, which means that initializers are run immediately and that's probably not
something you want. In comparison, code placed in an onAppear() modifier is called only
when the view is shown for the first time, so it's the right place to do complex work.

209.How can an observable object announce changes to SwiftUI?


Suggested approach: There are two primary ways this is done: using the @Published
property wrapper, or by calling objectWillChange.send() directly.
Try to provide examples of when one is preferable over the other, such as saying that you
might use @Published by default, switching over to objectWillChange.send() for times
when you need more fine-grained control.

210.How would you create programmatic navigation in SwiftUI?


Suggested approach: SwiftUI makes simple navigation as easy as it should be, but
programmatic navigation is trickier because you need to declare all your states up front.

If you want to talk about tags for NavigationLink views you can, but I would say the
important thing here is to think about why it's important – handling deep links from
Spotlight or widgets are both good places where you need to navigate programmatically.

211.Why does SwiftUI use structs for views?


Suggested approach: Start with the easiest answer, then work your way up: structs are used
because they are much simpler and much more efficient than classes. Once you've nailed
the basics, go on to discuss why this matters – SwiftUI is free to recreate your view structs
whenever and as often as it wants, so performance needs to be good.

212.Modifiers/Custom modifiers in SwiftUI?


SwiftUI gives us a range of built-in modifiers, such as font(), background(), and
clipShape(). However, it’s also possible to create custom modifiers that do something
specific.
For example, we might say that all titles in our app should have a particular style, so first
we need to create a custom ViewModifier struct that does what we want:

213. Containers in SwiftUI?


SwiftUI is designed to be composed right out of the box, which means you can place one
view inside another as much as you need.
This is particularly useful when working with the major container views we are used to,
such as navigation controllers and tab bar controllers. We can place any views we want
right into another container view, and SwiftUI will adapt its layout automatically.
In this regard, SwiftUI’s own containers – NavigationView, TabView, Group, and more –
are no different from containers we make with our own view composition.

214.How to create stacks using VStack, HStack and ZStack?


Our SwiftUI content views must contain one or more views, which is the layout we want
them to show. When we want more than one view on screen at a time you’ll usually want to
tell SwiftUI how to arrange them, and that’s where stacks come in.
Stacks – equivalent to UIStackView in UIKit – come in three forms: horizontal (HStack),
vertical (VStack) and depth-based (ZStack), with the latter being used when you want to
place child views so they overlap.

215.What is trailing closure?


If you need to pass a closure expression to a function as the function’s final argument and
the closure expression is long, it can be useful to write it as a trailing closure instead. You
write a trailing closure after the function call’s parentheses, even though the trailing closure
is still an argument to the function. When you use the trailing closure syntax, you don’t
write the argument label for the first closure as part of the function call. A function call can
include multiple trailing closures

216.Differences between TCP and UDP?

Transmission control protocol (TCP) User datagram protocol (UDP)

TCP is a connection-oriented protocol. UDP is the Datagram oriented protocol.


Connection-orientation means that the This is because there is no overhead for
communicating devices should establish opening a connection, maintaining a
a connection before transmitting data connection, and terminating a connection.
and should close the connection after UDP is efficient for broadcast and
transmitting the data. multicast type of network transmission.

TCP is reliable as it guarantees the The delivery of data to the destination


delivery of data to the destination cannot be guaranteed in UDP.
router.

TCP provides extensive error checking UDP has only the basic error checking
mechanisms. It is because it provides mechanism using checksums.
flow control and acknowledgement of
data.

Sequencing of data is a feature of There is no sequencing of data in UDP. If


Transmission Control Protocol (TCP). the order is required, it has to be managed
this means that packets arrive in-order by the application layer.
at the receiver.

TCP is comparatively slower than UDP. UDP is faster, simpler, and more efficient
than TCP.

Retransmission of lost packets is There is no retransmission of lost packets


possible in TCP, but not in UDP. in the User Datagram Protocol (UDP).

TCP has a (20-60) bytes variable length UDP has an 8 bytes fixed-length header.
header.

TCP is heavy-weight. UDP is lightweight.

TCP doesn’t support Broadcasting. UDP supports Broadcasting.

TCP is used by HTTP, HTTPs, FTP, UDP is used by DNS, DHCP, TFTP,
SMTP and Telnet. SNMP, RIP, and VoIP.

A short example to understand the differences clearly :


Suppose there are two houses, H1 and H2 and a letter has to be sent from H1 to H2. But
there is a river in between those two houses. Now how can we send the letter?
Solution 1: Make a bridge over the river and then it can be delivered.
Solution 2: Get it delivered through a pigeon.
Consider the first solution as TCP. A connection has to made ( bridge ) to get the data
(letter) delivered.
The data is reliable because it will directly reach another end without loss in data or error.
And the second solution is UDP. No connection is required for sending the data.
The process is fast as compare to TCP, where we need to set up a connection(bridge). But
the data is not reliable: we don’t know whether the pigeon will go in the right direction, or it
will drop the letter on the way, or some issue is encountered in mid-travel. types

217.Write a program to find largest number in array [1,2,3,5,8,6,9,7]?


var arr1 = [1,2,3,5,8,6,9,7]
for i in 1...arr1.count-1 {

if (arr1[0] < arr1[i]) {


arr1[0] = arr1[i];
}
}

print( arr1[0])

218.What are the programming languages used for iOS development?

Programming languages used for iOS development are:


• HTML5
• .NET
• C
• Swift
• Javascript
• Objective-C

219.What is Operator Overloading?


Operator overloading is used to work on how existing operators perform with types that
both already exist. Operators are those little symbols like +, *, and /.

220.How could you set up Live Rendering?


The attribute @IBDesignable lets Interface Builder perform live updates on a particular
view. IBDesignable requires Init frame to be defined as well in UIView class.

221.Explain Compilation Conditions?


Compilation Conditions to use if DEBUG … endif structure to include or disable given
block of code ve separate targets.

222.What is Regular expressions?

Regular expressions are special string patterns that describe how to search through a string.

223.What is TVMLKit?
TVMLKit is the glue between TVML, JavaScript, and your native tvOS application.

224.How is an inout parameter different from a regular parameter?


A Inout passes by reference while a regular parameter passes by value.

225.Determine the value of X in the Swift code below. Explain your answer?
Consider the code:
class Cricket
{
var score = 100
}
var player1 = Cricket() var player2 = player1 player2.score = 200 print((player1.score),
(player2.score))
Ans:200,200(Classes are reference type)

var a1 = [1, 2, 3, 4, 5]
var a2 = a1
a2.append(6)
var x = a1.count
Determine the value of x.
Answer: (Structs are reference type)
In Swift, arrays are implemented as structs, making them value types rather than reference
types (i.e., classes). When a value type is assigned to a variable as an argument to a function
or method, a copy is created and assigned or passed. As a result, the value of x or the count
of array a1 remains equal to 5 (answer) while the count of array a2 is equal to 6, appending
the integer 6 onto a copy of the array a1. The arrays appear in the box below.

226.A grandparent, parent and child problem?


Problem:
Take three objects: a grandparent, parent and child. The grandparent retains the parent, the
parent retains the child and the child retains the parent. The grandparent releases the parent.
Explain what happens.
Answer:
• Firstly, there is a retain cycle between the parent and the child.
• That will prevent any of the associated objects in the chain from being released from
memory.
• You would need to make one of the references "weak" or "unowned" between the
parent and child. This will remove a circular strong reference

227.Find the bug in the Objective-C code below. Explain your answer?
Problem:
Consider:
@interface HelloWorldController : UIViewController

@property (strong, nonatomic) UILabel *alert;

@end

@implementation HelloWorldController

- (void)viewDidLoad {
CGRect frame = CGRectMake(150, 150, 150, 50);
self.alert = [[UILabel alloc] initWithFrame:frame];
self.alert.text = @"Hello...";
[self.view addSubview:self.alert];
dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
sleep(10);
self.alert.text = @"World";
}
);
}

@end
Answer:
All UI updates must be performed in the main thread. The global dispatch queue does not
guarantee that the alert text will be displayed on the UI. As a best practice, it is necessary to
specify any updates to the UI occur on the main thread, as in the fixed code below:
dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
sleep(10);
dispatch_async(dispatch_get_main_queue(), ^{
self.alert.text = @"World";
});
});

228.Rewrite this code in a Swift way?


Problem:
Consider:
let list = [Int](1...5)
var arrayOfTuples = [(Int, Int)]()

for (index, element) in list.enumerated() {


arrayOfTuples += [(index, element)]
}

print(arrayOfTuples) // prints [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5)]
Can you rewrite this code in a more "swiftier" way?

Answer:
Yeap, the way to do it is:
let list = [Int](1...5)
let arrayOfTuples = Array(list.enumerated())
print(arrayOfTuples) // prints [(offset: 0, element: 1), (offset: 1, element: 2), (offset: 2,
element: 3), (offset: 3, element: 4), (offset: 4, element: 5)]
or with map:
let list = [Int](1...5)
let arrayOfDictionaries = list.enumerated().map { (a, b) in return [a : b] }
print(arrayOfDictionaries) // prints [[0: 1], [1: 2], [2: 3], [3: 4], [4: 5]]

229.What are the projects you were involved in so far? What technologies did you use
there?
just give some more details about some interesting projects, like what technologies, what
frameworks have you used, etc.

230.Are you involved in any open source projects? What is your role there?
that would be a big plus, even if you are just a contributor. If you are trying to get your first
job it's a good way to prove your skills. Even better if you are a maintainer of the popular
repository.
231.How big were the teams? Have you been a leader in any of those projects?
just to know if you used to work alone, in big teams, remotely or only with local people,
etc.

232.What are the sources of your knowledge? Do you read any blogs or listen to any
podcasts? Name a few.
if you do then that might mean programming is not just your job but also a hobby and it's
usually better to hire you instead of someone who doesn't do that

233.Have you worked with Scrum/Agile? What do you think about that? When in
your opinion it can be good and when rather harmful?
just a quick question to see if you understand that scrum has its place and doesn't have to be
used ALWAYS

234.What is your opinion on Code Review?


another quick question to check if you are either in a group of people who think it's
important or in the other one :)

235.Do you go to conferences and local meetups sometimes? Do you have any favorite
one?
nothing serious in my opinion, it doesn't mean that you are a bad developer because you do
not go there, you might be just an introvert. But it's sometimes good to see if you are a
person that might promote the company on conferences or even do a speech.

236.Consider two input arrays,


let listOne = [3,nil,5,7]
let listTwo = [4,6,2,8,nil]

By using high order functions, write code snippet to get a sum of all integers from both
Arrays?

Ans: 35
Higher order functions are simply functions that can either accept functions or closures as
arguments or return a function/closure.
Higher Order Functions are very useful and powerful and help us to write more elegantly
and maintainable code. Those functions are Map, Filter, Reduce, Sort, CompactMap etc.
let result =
[listOne.compactMap({ $0}),listTwo.compactMap({ $0})].flatMap({ $0}).reduce(0) { $0 +
$1 }
First compact map removes nil element from the array. Then by using a flat map, we
combine these two arrays.
And finally, reduce function will help to get the sum of array elements.

237.Bob developed an iOS application, uploaded on store successfully. Since he is


working for client XYZ, he chooses bundle-id com.xyz.appName for this music
application. But the later name of the organization changed now the client wants to
update bundle-id too.What are the possible ways to handle this?
As iOS developers we know, Bundle ID is a string that uniquely identifies an application in
the app store. So while developing the app we have to choose unique bundle-id for our app.
Apple recommends reverse domain name for this, like com.yourCompany.yourApp
For the above scenario. As apple guidelines say, once your application successfully
uploaded to store, you can’t change the bundle ID later. So always make sure that you
choose a bundle identifier that makes sense for the project and the owner.

238.For your photo-gallery iPad application, What would be your preference as senior
developer, Alamofire or URLSession?
With URLSession APIs availability, Now it becomes easier to build up network requests.
The developer can build own networking layer on top of URLSession.
Alamofire is popular Elegant HTTP Networking library in Swift. Alamofire saves you a ton
of time and simplifies the use. It is a well-tested library. Maintained by very clever people.
Cost of including it - very small.
For small projects and projects with less time-line Alamofire is a good choice.
But for long term product, we can build in the house layer with NSURLSession. To avoid
third-party dependency and upgrade overhead.

239.Almost all companies are taking the subject of data security and privacy severely.
So how to protect user's sensitive data in iOS applications.?
Apple provides great security mechanisms like Keychain, data encryption, or App Transport
Security(which forces developers to use SSL pinning).
Keychain is the password management system developed by Apple. Logins, keys, and
passwords should be stored in Keychain.
For network request, SSL pinning is used to ensure that an application communicates with
the right server. For this, we need to save the SSL certificate within the app bundle.
Others security mechanisms are like using encryption methods like AES-256 encryption
while saving sensitive data to persistent storage or passing data over the internet.

240.What will be output for below code snippet? Also, analyze the memory
performance for this code?

class Student {
let name: String
init(name: String) {
self.name = name
}
var scoreCard: ScoreCard?{
didSet{
print("\(name) got \(scoreCard!.marks) marks in this exam")
}
}
}
class Scorecard {
let marks: Float
init(marks: Float) {
self.marks = marks
}
var student: Student?{
didSet{
print("\(marks) for \(student!.name) in this exam")
}
}
}
var student: Student?
var score:Scorecard?
student = Student (name: "Albert Einstein")
score = Scorecard (marks: 80)
student!.scoreCard = score
score!.student = student
student = nil
score = nil

Albert Einstein got 80.0 marks in this exam 80.0 for Albert Einstein in this exam. Here we
have defines two classes, Student and ScoreCard. Each student owns one scoreCard also
Each scoreCard belongs to the specific student.
Finally, we have created a student with the name "Albert Einstein" and ScoreCard with 80
marks. We assigned scorecard to student and student to scorecard. Now both objects are
strongly referencing to each other. So they will never be removed from memory. This code
will cause a memory leak.
To fix this, we have to use weak reference for scoreCard property of student class.
class Student {
let name: String
init(name: String) {
self.name = name

}
weak var scoreCard: ScoreCard?{
didSet{
print("\(name) got \(scoreCard!.marks) marks in this exam")
}
}
}

241.What is the difference between the consumable and non-consumable type of in-
app purchase?
• Consumable: Customer needs to buy consumable in-app purchase items every time
for the following cases,
◦ If he deletes the old app and installs again.
◦ In case of a change in device. It’s used for,
◦ Game currency
◦ Game Hints
◦ Extra health
◦ Extra experience points
◦ A package of exports to a new file format etc.
• Non-consumable: This type is commonly used in-app purchase. It's like a one-time
purchase. Customer can use that feature with multiple devices using his Apple ID.
Even if you delete and re-install application you can still restore your purchase
features. It’s used for:
◦ Upgrade to pro edition
◦ Remove Ads
◦ Full game unlock
◦ Unlimited hints
◦ Extra characters
◦ Extra accessories
◦ Bonus game levels
◦ City guide maps

242.Swift is a static language and Objective-C dynamic language. What does it mean?
• Swift is static: The compiler must have all information about all classes and
functions at compile time. You can "extend" an existing class (with an extension),
but even then you must define completely at compile time what that extension
consists of.
• Objective-C is dynamic: Objective-C was extremely influenced by Smalltalk, which
had demonstrated the benefits of duck typing. This is also known as late binding,
runtime binding, or the late dispatch. It’s dynamic because the responder of a
message isn’t baked in at compile time, but is deferred until the actual point of
sending the message.

243.What is the output of the following Program? let numbers = [1, 2, 3, 4]?
let numberSum = numbers.reduce(0, { $0 + $1})
Ans:10

244.Structures can be inherited(True/False)?


False

245.What is the Output of Following Program var randomly Array: [AnyObject] =


[1,1.2,”Hello”] print (randomArray)?
Compilation Error (1 is an Int not object)

246.What is the Output Of Following Program?


class FirstClass {
func doFunction() {
print(“I am superclass")
}}
class SecondClass: Firstclass {
override func doFunction() {
print(“I am subclass")
}}
let object = SecondClass()
object.doFunction()

Ans:I am subclass

247.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.

248.what are binaries required to install the app to device?


.ipa,
.app

249.How much will you rate yourself in iOS?


When you attend an interview, Interviewer may ask you to rate yourself in a specific
Technology like iOS, So It's depend on your knowledge and work experience in iOS.
226.What challenges did you face while working on iOS?
This question may be specific to your technology and completely depends on your past
work experience. So you need to just explain the challenges you faced related to iOS in
your Project.

250.How much experience do you have in iOS?


Here you can tell about your overall work experience on iOS.

251.Have you done any iOS Certification or Training?


It depends on the candidate like you have done any iOS training or certification.
Certifications or training are not essential but good to have.

252.what OAuth?

Open Authorization is often referred to as OAuth, which is generally an authorization


protocol and not used for authentication. As OAuth is an authorization protocol, it is just
concerned with authorization of third-party application that can be used to access user data
without identifying the user or exposing its credentials. It has two libraries namely, OAuth2
and OAuthSwift

253.Why Choose Struct Over Class?


According to the very popular WWDC 2015 talk Protocol Oriented Programming in Swift
(video, transcript), Swift provides a number of features that make structs better than classes
in many circumstances.
Structs are preferable if they are relatively small and copiable because copying is way safer
than having multiple references to the same instance as happens with classes. This is
especially important when passing around a variable to many classes and/or in a
multithreaded environment. If you can always send a copy of your variable to other places,
you never have to worry about that other place changing the value of your variable
underneath you.
With Structs, there is much less need to worry about memory leaks or multiple threads
racing to access/modify a single instance of a variable. (For the more technically minded,
the exception to that is when capturing a struct inside a closure because then it is actually
capturing a reference to the instance unless you explicitly mark it to be copied).
Classes can also become bloated because a class can only inherit from a single superclass.
That encourages us to create huge superclasses that encompass many different abilities that
are only loosely related. Using protocols, especially with protocol extensions where you can
provide implementations to protocols, allows you to eliminate the need for classes to
achieve this sort of behavior.
The talk lays out these scenarios where classes are preferred:
• Copying or comparing instances doesn't make sense (e.g., Window)
• Instance lifetime is tied to external effects (e.g., TemporaryFile)
• Instances are just "sinks"--write-only conduits to external state (e.g.CGContext)
It implies that structs should be the default and classes should be a fallback.
On the other hand, The Swift Programming Language documentation is somewhat
Structure instances are always passed by value, and class instances are always passed by
reference. This means that they are suited to different kinds of tasks. As you consider the
data constructs and functionality that you need for a project, decide whether each data
construct should be defined as a class or as a structure.
As a general guideline, consider creating a structure when one or more of these conditions
apply:
• The structure’s primary purpose is to encapsulate a few relatively simple data values.
• It is reasonable to expect that the encapsulated values will be copied rather than
referenced when you assign or pass around an instance of that structure.
• Any properties stored by the structure are themselves value types, which would also
be expected to be copied rather than referenced.
• The structure does not need to inherit properties or behavior from another existing
type.
Examples of good candidates for structures include:
• The size of a geometric shape, perhaps encapsulating a width property and a height
property, both of type Double.


A way to refer to ranges within a series, perhaps encapsulating a start property and a
length property, both of type Int.
• A point in a 3D coordinate system, perhaps encapsulating x, y and z properties, each
of type Double.
In all other cases, define a class, and create instances of that class to be managed and passed
by reference. In practice, this means that most custom data constructs should be classes, not
structures.
Here it is claiming that we should default to using classes and use structures only in specific
circumstances. Ultimately, you need to understand the real world implication of value types
vs. reference types and then you can make an informed decision about when to use structs
or classes. Also, keep in mind that these concepts are always evolving and The Swift
Programming Language documentation was written before the Protocol Oriented
Programming talk was given.

254.Combine Framework in iOS?


Combine, announced at WWDC 2019, is Apple’s new “reactive” framework for handling
events over time. You can use Combine to unify and simplify your code for dealing with
things like delegates, notifications, timers, completion blocks and callbacks. There have
been third-party reactive frameworks available for some time on iOS, but now Apple has
made its own.
In this tutorial, you’ll learn how to:
• Use Publisher and Subscriber.
• Handle event streams.
• Use Timer the Combine way.
• Identify when to use Combine in your projects.
The Combine framework provides a declarative API to process values over time. There are
three main components:
1. Publishers: Things that produce values.
2. Operators: Things that do work with values.
3. Subscribers: Things that care about values.

255. Publishers in Combine Framework?


Publishers:
Objects that conform to Publisher deliver a sequence of values over time. The protocol has
two associated types: Output, the type of value it produces, and Failure, the type of error it
could encounter.
Every publisher can emit multiple events:
• An output value of Output type.
• A successful completion.
• A failure with an error of Failuretype.
Several Foundation types have been enhanced to expose their functionality through
publishers, including Timer and URLSession, which you’ll use in this tutorial.

256. Operators in Combine Framework?


Operators:
Operators are special methods that are called on publishers and return the same or a
different publisher. An operator describes a behavior for changing values, adding values,







removing values or many other operations. You can chain multiple operators together to
perform complex processing.
Think of values flowing from the original publisher, through a series of operators. Like a
river, values come from the upstream publisher and flow to the downstream publisher.

257. Subscribers in Combine Framework?


Subscribers:
Publishers and operators are pointless unless something is listening to the published events.
That something is the Subscriber.
Subscriber is another protocol. Like Publisher, it has two associated types: Input and
Failure. These must match the Output and Failure of the publisher.
A subscriber receives a stream of value, completion or failure events from a publisher.
A publisher starts delivering values when you call subscribe(_:) on it, passing your
subscriber. At that point, the publisher sends a subscription to the subscriber. The subscriber
can then use this subscription to make a request from the publisher for a definite or
indefinite number of values.
After that, the publisher is free to send values to the Subscriber. It might send the full
number of requested values, but it might also send fewer. If the publisher is finite, it will
eventually return the completion event or possibly an error.

258.Static vs Dynamic Dispatch in Swift?


To start things off, Static Dispatch is supported by both value types and reference types.
However, Dynamic Dispatch is supported only by reference types(i.e. Class). The reason
for this is that, for dynamism, or dynamic dispatch, in short, we need inheritance and our
value types do not support inheritance.
Now how do we achieve both of them in Swift ?
• To achieve Dynamic Dispatch, we use inheritance, subclass a base class and then
override an existing method of the base class. Also, we can make use of dynamic
keyword and we need to prefix it with @objc keyword so as to expose our method to
Objective-C runtime
• To achieve Static Dispatch, we need to make use of final and static as both of them
ensures that the class and method cannot be overridden.
Dynamic dispatch increases language expressivity at the cost of a constant amount of
runtime overhead. What that means is that for every call to a method, in case of dynamic
dispatch, our compiler will have to look inside what we call a witness table (virtual table or
dispatch table in other languages) for checking the implementation of that particular
method. The compiler needs to determine whether you referring to the superclasses’
implementation or are you referring to the implementation of the subclass. And since
memory to all the objects is allocated at runtime, the compiler can only perform that check
at runtime.
Static dispatch, however, does not have this problem. With this dispatch technique, the
compiler knows, at compile-time, which method implementation is to be called for a
method. Thus the compiler can perform certain optimizations and can even convert the code
to Inline, if possible, thus making the overall execution speed insanely fast!

259.Static and Class Keyword in Swift?


Before we talk about how static and class keyword are different with each other, lets see
how they are similar.
How They Are Similar?
Static and Class keyword when applied on a variable or function, make it Type method.
Type Methods are the methods which you can call directly without creating instance of the
class. Whereas, in Instance Method, we need to create an instance of the class first to access
the property.
Static:
Can be applied on Stored Property as well as Computed Properties.
Static method declaration are allowed in Struct as well as Classes.
Static properties can not be overridden by inheriting classes.
Class:
Can only be applied on Computer Properties.
Class keyword can only be used in Classes.
Class properties can be overridden by inheriting classes.
static keyword is same like final class. final keyword makes the variable or function final
i.e. they can not be overridden by any inheriting class.

260.How to split this array [0, 1, 2, 0, 1, 2] to subarray off 0,1,2?


extension Array {
func chunked(into size: Int) -> [[Element]] {


return stride(from: 0, to: count, by: size).map {


Array(self[$0 ..< Swift.min($0 + size, count)])
}
}
}
var input = [0, 1, 2, 0, 1, 2]

let name=input.sorted()
let numbers = name
let result = numbers.chunked(into: 2)
print(result)

let numberGroups = Set(input).map{ value in return input.filter{$0==value} }

print(numberGroups)

261.I didn't hear back immediately after my interview. Am I rejected?


No. There are a number of reasons why a company's decision might be delayed. A very
simple explanation is that one of your interviewers hasn't provided their feedback yet. Very,
very few companies have a policy of not responding to candidates they reject.
If you haven't heard back from a company within 3 - 5 business days after your interview,
check in (politely) with your recruiter.

262.Can I re-apply to a company after getting rejected?


Almost always, but you typically have to wait a bit (6 months to a 1 year). Your first bad
interview usually won't affect you too much when you re-interview. Lots of people get
rejected from Google or Microsoft and later get offers from them.

263.Why do you want to work for Microsoft?


In this question, Microsoft wants to see that you're passionate about technology. A great
answer might be, "I've been using Microsoft software as long as I can remember, and I'm
really impressed at how Microsoft manages to create a product that is universally excellent.
For example, I've been using Visual Studio recently to learn game programming, and its
APls are excellent:' Note how this shows a passion for technology!

264.How you will store user info (username, password or token) securely in iOS?
You should always use Keychain to store usernames and passwords, and since it’s stored
securely and only accessible to your app, there is no need to delete it when app quits.

You might also like