· 6 years ago · Mar 08, 2019, 03:50 PM
1Question
2

3

4Theory Concepts :-
5

6- Json
7- Rest
8- NSSession vs NSURLConnection
9- XML parsing
10- Soap Parsing
11- Property type
12- Strong vs Weak
13- Deangling Pointer
14- NSSet Vs NSArray
15- Delegate Vs Protocol
16- Notification (KVO,KVC,NSNotificationCenter)
17- Swift features,adv,disadvantage,version
18- Difference between NULL - C type pointer ,Nil - is objcet pointer to nothing vs NSNULL- A nil boxed as an object for storage in a collection.eg. to store blank value in array kind of collection,you can use NSNull.
19- Segue
20- Autolayout
21- Database
22- Asyncimageview
23- Design Pattern
24- Tableview methods
25- Threading
26- Block Programing
27- Queue
28- Application State or lifecycle
29- GCD vs NSOperationQueue vs NSThread
30- MVC (Solution is MVVM)
31

32- latest version of iOS
33- it’s feature
34

35http://www.techrepublic.com/blog/software-engineer/understand-the-states-and-transitions-of-an-ios-app/
36- Not Running :- Application is still not launched or not in opened
37- Inactive :- Application is in foreground but not receiving events.
38- Active :- Application is in foreground and receiving events.
39- Background :- Application is in background but executing code.or most of apps comes in way to suspended mode.
40- Suspended:- Application is in background but not executing code system put app automatically in this mode.Even application don’t receive any notification to go into this mode.
41

42Practical :-
43

44- Parsing JSON with POST
45- TableView custom table show asyncimageview
46- Cell button to navigate with location data
47- Next page map pin show
48

49

50

51Q1) OOPS Concept:-
52

53Q2) ARC and MRC
54

55Q3)Property
56

57A3) http://www.ios-blog.co.uk/tutorials/objective-c/objective-c-property-attribute-reference-guide/
58https://academy.realm.io/posts/tmi-objective-c-property-attributes/

59Â
60

61atomic:- Define property as atomic not guaranty thread safe but it return viable result when situation like thread a is executing getter but thread b calls the setter.
62

63nonatomic
64

65

66strong
67

68weak
69

70

71readwrite
72

73read only
74

75

76copy
77

78

79assign :- Pre arc attribute
80

81retain :- Pre arc attribute
82

83unsafe_unretain :- Pre arc attribute
84

85

86Q4)Block
87

88

89http://www.appcoda.com/objective-c-blocks-tutorial/
90

91

92Q5) GCD
93

94————————————————————————————————————————————— icoderz solution
95

96Q.1) Introduce about urself
97

98Q.2) OOPS Concept
99

100Q.3) NSURLConnection Vs NSURLSession
101

102

103NSURLSession :-
104

105If your app needs more control over your request, such as controlling whether redirects are followed, performing custom authentication, or obtaining the data piecewise as it is received, you can use the NSURLSession class with a custom delegate.
106

107

108Diiference NSURLSession vs NSURLConnection :-
109

110

1111) When you create an NSURLSession object, you provide a reusable configuration object that encapsulates many common configuration options. With NSURLConnection, you must set those options on each connection independently.
112

113

1142)An NSURLConnection object handles a single request and any follow-on requests. An NSURLSession object manages multiple tasks, each of which represents a single URL request and any follow-on requests. You usually create a session when your app launches, then create tasks in much the same way that you would create NSURLConnection objects.
115

116

1173)With NSURLConnection, each connection object has a separate delegate. With NSURLSession, the delegate is shared across all tasks within a session. If you need to use a different delegate, you must create a new session. When you initialize an NSURLSession or NSURLConnection object, the connection or session is automatically scheduled in the current run loop in the default run loop mode.
118

119

1204)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).
121

122

1235)NSURLSession also provides grouping of related requests, making it easy to cancel all of the requests associated with a particular work unit.
124

125

1266)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., whereas with NSURLConnection, if you suddenly realized you needed to do those things, you had to refactor your code to not use block-based callbacks.
127

128

129http://hayageek.com/ios-nsurlsession-example/
130

131NsurlConnection delegate method.
132

133Â 1.didReceiveResponse
134

135Â 2.didReceiveData
136

137Â 3.didFailWithError
138

139Â 4.connectionDidFinishLoading
140

141

142NSURLSession
143

144Create Data task with system provided Delegate methods.
145

1461- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request;
147

1482- (NSURLSessionDataTask *)dataTaskWithURL:(NSURL *)url;
149

1503-didReceiveResponse
151

1524-didReceiveData
153

154

155

156Q.4)Delegate method of NSURLSession
157

158Q.5)Delegate method of TableView
159DELEGATE :-
160

161tableview:heightForRowAtIndexPath
162indenetationLevelForRowAtIndexPath
163willSelectRowAtIndexPath
164didSelectRowAtIndexPath
165

166

167DATASOURCE :-
168numberOfSectionsInTableView
169numberOfRowsInSection
170cellForRowAtIndexPath
171

172

173

174Q.6)Delegate method of Collectionview
175

176Q.7)how work IN app purchase
177

178Q.8)Notification push and local and what can we do
179

180Q.9)New in iOS 9
181- multitasking
182- 3d touch
183- app thinning
184- support right to left language
185- app transport security
186-contact and contacts ui
187-live photo
188

189Q.10)New in iOS10
190- iMessage +apps
191- map + apps
192- phone + apps enable voip calls
193- siri +apps
194- Rich notification
195- Notification supports video, audio, and images.
196- Notification gets displayed even if App is in foreground
197- Add actions to notification
198- Enable quick reply text
199- GIF image support
200- Customized User Interface for notification
201- get notification though user in foreground
202

203Q.11) Bundle id Vs app id
204

205- mention in .plist - object in member centre
206- unique for each app - can be used for multiple apps
207- it is represent as app identifier - it is connection between app and provisions profile
208- - two types of app id 1)explicit app id (same id used for single app) 2)wildcard app id(same id used for multiple app)
209

210Q.12) lifecycle of app
211

212

213- Not Running :- Application is still not launched or not in opened
214- Inactive :- Application is in foreground but not receiving events.
215- Active :- Application is in foreground and receiving events.
216- Background :- Application is in background but executing code.or most of apps comes in way to suspended mode.
217- Suspended:- Application is in background but not executing code system put app automatically in this mode.Even application don’t receive any notification to go into this mode.
218

219-----------------------------------------------------------------------------------------------------------------------------------------------------------------
220Q.1) BLE
221Q.2)Beacon
222Q.3)Application didfinishlaunching with option in which option does what thing and what if we return No.
223Q.4)Application DidFinishLanuch dictionary means
224ans)Â methods provide a dictionary with keys indicating the reason that your app was launched.
225Q.4)what is meaning of Dispatch
226Execute code concurrently on multicore hardware by submitting work to dispatch queues managed by the system.
227

228Q.5)can we download multiple images on background while using dispatch queue.
229not sure answer
230http://stackoverflow.com/questions/14898994/ios-how-do-i-asynchronously-download-and-cache-images-and-videos-for-use-in-my-a/37085817#37085817
231

232Q.6)push notification which method called when application in foreground and we yet not clicked on pushnotification.
233
234The UserNotifications framework (UserNotifications.framework) supports the delivery and handling of local and remote notifications. You use the classes of this framework to schedule the delivery of local notifications based on specific conditions, such as time or location. Apps and extensions also use this framework to receive and potentially modify local and remote notifications when they are delivered to the user’s device.
235
236
237https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/SchedulingandHandlingLocalNotifications.html#//apple_ref/doc/uid/TP40008194-CH5-SW14
238

2391)slient notification(by deafault) (this will update data silently directly to your app)
2402) view notification in foreground by implementing willPresentNotification method
241

242Q.7)What can achieve trough swift but not by using objective c?
243Q.8)What is tuple in swift?
244Q.9)What is advantage of swift?
245Q.10 )What is core data?What is model in it?
246Q.11)What is NSPredicate?How to use NSPredicate with example?
247NSPredicate is a Foundation class that specifies how data should be fetched or filtered. Its query language, which is like a cross between a SQL WHERE clause and a regular expression, provides an expressive, natural language interface to define logical conditions on which a collection is searched.
248
249let bobPredicate = NSPredicate(format: "firstName = 'Bob'")
250let smithPredicate = NSPredicate(format: "lastName = %@", "Smith")
251let thirtiesPredicate = NSPredicate(format: "age >= 30")
252
253(people as NSArray).filteredArrayUsingPredicate(bobPredicate)
254

255------------------------------------------------------------------------------------------------
256Q.1) NSArray Vs NSSet
257Q.2) if i have vc1-vc2-vc3-vc4-vc5 rest of vc3 and vc4 all are pushed in navigation controller but vc3 and v4 present modelling so tell me way to add vc3 and vc4 to add in navigation stack?
258https://stackoverflow.com/questions/25444213/presenting-viewcontroller-with-navigationviewcontroller-swift

259Q.3) join two array and add into one array in ios without using third array
260

261one way)
262NSMutableSet *set = [NSMutableSet setWithArray:array1];
263[set addObjectsFromArray:array2];
264NSArray *array = [set allObjects];
265

266

267Q.4) in app purchase
268Q.5) PayPal payment modes
269

270- single payments :- for single payments, your app can accept paypal payments
271- future payments :- you can store payment information to accept ongoing payments.
272

273Q.6) QRCode done using which framework
274- AVFoundation Framework
275- AVCaptureSession
276-AVCaptureVideoPreviewLayer
277delegate
278-AVCaptureMetadataOutputObjectsDelegate
279

280Q.7) how to do FbLogin
281Q.8) if there is one thousand images in tableview how to load only only 10 images though i scroll whole 1000 images.sdimageview
282Ans 8)probable answer
283

284[[SDWebImagePrefetcher sharedImagePrefetcher] prefetchURLs:<NArray with image URLs>];
285This will handle the concurrent download issue for you (maxConcurrentDownloads).
286

287

288Q.9) async vs sync
289Q.10) kvo and kvc
290Q.11) difference between NSNotificationcenter vs KVO
291Q.12) Difference between app id vs fb secreate key
292- The App ID is a public identifier for your application.
293- It's something consuming code can use to identify the application.
294

295-The App Secret is a private key your code can use to identify you as the owner of the application, so you can perform operations non-owners should not be able to perform.
296

297Q.14)What is coreData?
298

299

300-SQLite database is the default persistent store for Core Data on iPhone, Core Data is not a relational database.
301-It is actually a framework that lets developers store (or retrieve) data in database in an object-oriented way.
302- With Core Data, you can easily map the objects in your apps to the table records in the database without even knowing any SQL.
303

304Q.13) core data vs normal database
305http://mobbook.generalassemb.ly/week07/core-data.html
306

307Q.14) persistance context object can be create multiple object or sql database context can be create multiple time ?
308http://commandshift.co.uk/blog/2013/06/06/multiple-persistent-stores-in-core-data/
309

310Design pattern :-
311creational :- singleton --- ensure that only one instance exists for given class and there is global access point to that instance.
312abstract factory
313structural :- mvc,decorator,adapter,facade and composite
314behaveourial:- observer,memento,chain of responsibility and command
315

316Q.15) category ,Extension
317

318category is used modularize a class by spreading its implementation over many files.Or to emulate to protected methods.
319Most common use to add methods in built in data type like NSString,NSArray.
320The advantage of this is that you don’t have to update existing code to use a new subclass,
321but you need to be very careful not to override existing functionality.
322

323ex. car class
324car+maintainance
325

326extension (empty category)
327extension is similar to category but incontrast to categories, an extension' API must be implemented in the main implementation file(in Car class not in CAR MAINTAINCE class)- it cannot be implemented in a category.
328Private method can be emulated using extension.
329

330http://rypress.com/tutorials/objective-c/categories
331-----------------------------------------------------------------------------------------------------------------------
332Q1. Howmany way to pass data from one vc to another vc?
333http://www.ioscorner.com/2014/07/different-ways-of-passing-data-between.html
334Q.2 IBInspectable and IBDesignable
335IBInspectable is set property using ib from runtime class attribute
336IBDesignable :-@IBDesignable designation lets Interface Builder know that it should render the view directly in the canvas. This allows seeing how your custom views will appear without building and running your app after each change.
337
338
339Q.3 coredata basic terminology
340http://mobbook.generalassemb.ly/week07/core-data.html
341NSManagedObject :- model object
342NSManagedObjectContext :- Represent single object space .. its primary responsibility is to manage a collection of managed object.
343NSPersistanceStore:- Abstract base class for all core data persistent stores, will typically represent a sqlite db.
344NSPersistanceStoreCoordinates :- Associate persistent stores with a model and serve to mediate between the persistent and the managed object context
345NSSortDescriptor - Defines the sorting mechanism for a set of objects.
346

347--------------------------------------------------------------------------------------------------------------------------------
348prac stack
349fblogin
3501. display product using db --- also user can choose products
3512. view cart where user can modify cart
352

353--------------------------------------------------------------------------------------------------------------------------------
354prac r
355

356- display, insert ,update and delete using POST but api is not json formatted
357- TIPS : result can not convert to json objects
358- display api also send parameters to like {"data":"content_all"}
359--------------------------------------------------------------------------------------------------------------------------------
360
361
362How to achieve operator overloading?
363Difference between closure and function?
364function have name closure don’t have.Closure are like function but it capture value from environment.Though nested function also capture value.
365
366
367Achieve multiple inheritance in swift?
368
369Can I use delegate for parent to child Viewcontroller? ans.embedded segue
370https://stackoverflow.com/questions/29582200/how-do-i-get-the-views-inside-a-container-in-swift
371
372What if I explicitly alloc init singleton object again?
373
374Difference between valueforkey and objectfor key?
375When you do valueForKey: you need to give it an NSString, whereas objectForKey: can take any NSObject subclass as a key. This is because for Key-Value Coding, the keys are always strings.
376
377In fact, the documentation states that even when you give valueForKey: an NSString, it will invoke objectForKey: anyway unless the string starts with an @, in which case it invokes [super valueForKey:], which may call valueForUndefinedKey: which may raise an exception.
378
379
380How many way to sort data?
381compare method (NSCompare)
382NSSortDescriptor
383Blocks
384
385https://stackoverflow.com/questions/805547/how-do-i-sort-an-nsmutablearray-with-custom-objects-in-it
386
387inout variable?
388
389In vc1 declare variable and I want to access it in closure how can I do?
390
391What if i dont close database after performing operations?
392memory leaks and performance issue
393
394Can i define property in category objective c?
395for setter method using obj_setAssocitaedObject and for getter manually write getter ()
396http://kaspermunck.github.io/2012/11/adding-properties-to-objective-c-categories/
397
398
399How can i restore my purchase of non renewing subscription?
400Non-renewing subscriptions are consumable. Therefore they cannot be restored. A restore button therefore makes no sense. You also need some kind of authentication/login system for the user.
401https://stackoverflow.com/questions/23931586/does-non-renewing-subscription-requires-a-restore-button
402
403Why gcd comes if it can done same thing using perform selector on background thread?
404
405

406Swift
407

4081. lazy keyword
409
410example of when to use lazy initialization is when the initial value for a property is not known until after the object is initialized.
411
412lazy variables are created using a function you specify only when that variable is first requested. If it's never requested, the function is never run, so it does help save processing time.
413There are five important things to note in that code:
414* The lazy property is marked as lazy var. You can't make it lazy let because lazy properties must always be variables.
415* Because the actual value is created by evaluation, you need to declare its data type up front. In the case of the code above, that means declaring the property as Int.
416* Once you've set your data type, you need to use an open brace ("{") to start your block of code, then "}" to finish.
417* You need to use self inside the function. In fact, if you're using a class rather than a structure, you should also declare [unowned self] inside your function so that you don't create a strong reference cycle.
418* You need to end your lazy property with (), because what you're actually doing is making a call to the function you just created.
419https://mikebuss.com/2014/06/22/lazy-initialization-swift/
420
421
4222. String vs NSString (Swift String is structure and NSString is a class and inherit from NSObject)
4233. if let
424https://medium.com/@abhimuralidharan/swift-optionals-simplified-swift-3-0-8d4b67fcf3c4
425
426Unwrapping optionals
427It can be done in few ways:
428â—™ Force unwrapping (Force unwrap is not recommended its error prone)
429
430var myOtherString:String?
431let x = myOtherString! // forced unwrapping Error. The value is not set.
432
433â—™ Implicit unwrapping (Implicit unwrapping is error prone and is not recommended)
434The only change is that this time the compiler will not yell at you. You can use it like a normal variable. Such optional variables will unwrap automatically and you do not need to use any further exclamation mark at the end of the variable to get the assigned value.This way of unwrapping is called implicit unwrapping .But keep in mind that the risk of crashing is high as you will have to manually keep track of the variable usage.
435
436By using an implicitly unwrapped optional, we are guaranteeing the compiler that we will assign some value to it sometimes in the future.
437
438class Vehicle {
439var model: String! //this ! is used to make variable implicit unwrap
440}
441var cars = Vehicle()
442print(cars.model) // it may crash the app sometimes. the value is nil.
443
444â—™ Optional binding (This is the recommended way of unwrapping an optional.)
445Use 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.
446An optional binding for the if statement is as follows −
447
448if let constantName = someOptional {
449 //statements using 'constantName'
450} else {
451// the value of someOptional is not set (or nil).
452}
453
454Q) Difference between guard and if let (optional binding)
455A)
4561)Constants and variables created with optional binding in an if statement are available only within the body of the if statement.
457- In contrast, the constants and variables created with a guard statement are available in the lines of code that follow the guard statement.
4582)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 thrown. It provides an early exit and fewer brackets. Early exit means faster execution.If the condition is true, Swift ignores the guard block.
459
460Q)Defer
461A) before leaving block it is used to clean up the code.
462You use a defer statement to execute a set of statements just before code execution leaves the current block of code. This statement lets you do any necessary cleanup that should be performed regardless of how execution leaves the current block of code—whether it leaves because an error was thrown or because of a statement such as return or break. For example, you can use a defer statement to ensure that file descriptors are closed and manually allocated memory is freed.
463
464A defer statement defers execution until the current scope is exited. This statement consists of the deferkeyword and the statements to be executed later. The deferred statements may not contain any code that would transfer control out of the statements, such as a break or a return statement, or by throwing an error. Deferred actions are executed in reverse order of how they are specified—that is, the code in the first deferstatement executes after code in the second, and so on.
465
466func doSomething() {
467defer { print(“1â€)}
468defer { print(“2â€)}
469defer { print(“3â€)}
470if 1<2 {
471defer { print("1<2")}
472}
473defer { print(“4â€)}
474defer { print(“5â€)}
475defer { print(“6â€)}
476}
477The defer statement inside the if code block will be executed first. Then it follows a LIFO pattern to execute the rest of the defer statements.
478
479
480What is the nil coalescing operator?
481If optional has value it unwrape that optional value or it will provide default value.
482Ex.let name: String? = nil
483let unwrappedName = name ?? "Anonymous"
484
485Q) mutateting (by using mutating func you can also make change in property value )
486
487Notice that this function actually changes the width and height variables of the rectangle. So this is where you have to use the mutating keyword – when you’re actually changing the variables in your struct!
488
489struct Rectangle {
490Â Â Â Â var width = 1
491Â Â Â Â var height = 1
492Â
493Â Â Â Â mutating func scaleBy(value: Int) {
494Â Â Â Â Â Â Â Â width *= value
495Â Â Â Â Â Â Â Â height *= value
496Â Â Â Â }
497}
498
499
500
5015. class vs struct
5026. enumeration
5037. optional chaining
5048. Error handling
5051. propagating errors
506To indicate that a function, method, or initializer can throw an error, you write the throws keyword in the function’s declaration after its parameters.
5072. do catch
508You use a do-catch statement to handle errors by running a block of code. If an error is thrown by the code in the do clause, it is matched against the catch clauses to determine which one of them can handle the error.
5093. Converting Errors to Optional Values
510You use try? to handle an error by converting it to an optional value. If an error is thrown while evaluating the try? expression, the value of the expression is nil.
511ex. . let x = try? someThrowingFunction()
5124.Disabling Error Propagation
513Sometimes you know a throwing function or method won’t, in fact, throw an error at runtime. On those occasions, you can write try! before the expression to disable error propagation and wrap the call in a runtime assertion that no error will be thrown. If an error actually is thrown, you’ll get a runtime error.
5149.Type Casting
515Type casting is a way to check the type of an instance, or to treat that instance as a different superclass or subclass from somewhere else in its own class hierarchy.
516Type casting in Swift is implemented with the is and as operators. These two operators provide a simple and expressive way to check the type of a value or cast a value to a different type.
5171. is (check type or check instance is of super class type or subclass type of) return BOOL
5182. downcasting
519

52010.guard let
5211. guard let with where clause
5222. if let
523https://medium.com/@abhimurallidharan/if-let-if-var-guard-let-and-defer-statements-in-swift-4f87fe857eb6
524

525Q)If nav-vc1-vc2-vc3-present-vc4-vc5
526Now tell me way to vc5 to vc1 and vc3?
527Q) is it possible to get location background completely even if our app is in not in background.
528https://medium.com/@calvinlin_96474/ios-11-continuous-background-location-update-by-swift-4-12ce3ac603e3
529
530Q)how to download specific number of image without downloading all images
531Q)how to get data from push notifications and also save data into database
532https://medium.com/posts-from-emmerge/ios-push-notification-background-fetch-demystified-7090358bb66e
533
534Q) when to use xib and when to use storyboard?
535Q) diff viewdidappear and viewwillappear
536

537NSDictionary (Extension)
538-(id)NSNullToNilForKey:(NSString*)key
539{
540Id value=[self valueForKey:key];
541return value! = [NSNull null] ? value : nil;
542
543
544Q. what if two NSString contain same data it will hold two memory location in memory or one?
545yes
546https://stackoverflow.com/questions/17364452/getting-same-memory-address-for-nsstrings-assigned-from-string-literals
547
548Q.class store in heap/stack
549ans)Classes (reference types) are allocated in the heap, value types (like Struct, String, Int, Bool, etc) live in the stack.Stack is very fast then heap.
550
551Q.structure store in heap/stack
552Q.what is open access control (may in swift)
553open :- An open class is accessible and subclassable outside of the defining module. An open class member is accessible and overridable outside of the defining module.
554
555public:- public class is accessible but not subclassable outside of the defining module. A publicclass member is accessible but not overridable outside of the defining module.
556
557internal (by default) :- accessed within same module but if you import that module it will not allowed to access it.
558Ex you define internalmethod in uikit.
559Even if we import UIKit, we cannot use the internalMethod() inside our ViewController. It can only be accessed anywhere within the same module of UIKit.
560
561
562 internal is the default access level. Internal classes and members can be accessed anywhere within the same module(target) they are defined. You typically use internalaccess when defining an app’s or a framework’s internal structure.
563
564filePrivate :-You typically use fileprivate access to hide the implementation details of a specific piece of functionality when those details are used within an entire file. ie; the functionality defined with a fileprivate access level can only be accessed from within the swift file where it is defined.
565
566Private :- access restricts the use of an entity to the enclosing declaration, and to extensions of that declaration that are in the same file
567
568class A {
569 private var name = "First Letter"
570}
571extension A {
572func printName(){
573print(name) // you may access it here from swift 4. Swift 3 will throw error.
574}
575}
576A()
577A().name // Error even if accessed from outside the class A{} of A.swift file.
578
579
580https://medium.com/@abhimuralidharan/swift-3-0-1-access-control-9e71d641a56c
581
582Q.when prefix.pch used?
583Prefix.pch is a precompiled header. Precompiled headers were invented to make compiling faster. Rather than parsing the same header files over and over, these files get parsed once, ahead of time.
584A prefix header is implicitly included at the start of every source file.
585
586Q.by which way you can make variable count to 3 to 0 in one line
587Q.types of notifications?
588ans)The three technical types she outlined were push, local, and in-app.
589
590Q.Closure @escaping and non escaping:-
591 Closure which is stored in function or run in background even after function return must define as @escaping.
592 e.g.. if closure with in dispatchQueue.global.async then that closure must be pass as @escaping
593
594 By default normal function/closures are non escaping (That means closure deallocate(removed) after function returns).
595benefit of normal function/
596closure it doesnot have retain cycle and memory leak