m.smartcloud.io/ios-interview-questions-for-senior-developers-in-2017-a94cc81c8205
https://github.com/onthecodepath/iOS-Interview-Questions/blob/master/README.md

https://www.raywenderlich.com/110982/swift-interview-questions-answers

https://www.toptal.com/swift/interview-questions

View story at Medium.com
View story at Medium.com
View story at Medium.com
View story at Medium.com

What is the difference between var and let?

var is a variable that can be changed while let denotes a constant that cannot be changed once set.

What is the difference between implicit and explicit?
When referring to something as implicit or explicit, it is often referring to how an object is declared. In the two examples below:

var name: String = "onthecodepath" // explicit
var name = "onthecodepath" // implicit 

In the first line above, the name variable is explicitly declared since the type of the variable follows the name of the variable. In the second line, the String type is not explicitly declared. However, Swift is able to infer that name is of a String type since the value that it is being set as is of a String type.

1. What is the question mark (optional) ? in Swift?

Answer: 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 (see below) and a variant of this example is in conditional clauses.

var optionalName : String? = “John"
if optionalName != nil {
    print(“Your name is \(optionalName!)”)
}

2: What is the use of exclamation mark !?

Answer: 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).

Question 3: How should one handle errors in Swift?

Answer: 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 throwskeyword 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()

Question 4: What is a guard statement in Swift?

Answer: Guard statements are a nice little control flow statement that can be seen as a great addition if you’re into a defensive programming style (which you should!). It basically evaluates a boolean condition and proceeds with program execution if the evaluation is true. A guard statement always has an else clause, and it must exit the code block if it reaches there.

guard let courses = student.courses! else {
    return
}

1. What is Enum ?
==> Enum is a data type that contains a group of related values. for ex. we can create enum for months. like enum named month which can contain all months name. if we tried to access Monday using months enum it will give error.

2. Why don’t we use strong for enum property in Objective-C ?
==> Because enums aren’t objects, so we don’t specify strong or weak here

14. The following code snippet results in a compile time error:

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!
  }
}

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

3. What is reuseIdentifier?
==> 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.

14- What’s Completion Handler ?  ==> Completion handlers are super convenient when our app is making an API call, and we need to do something when that task is done, like updating the UI to show the data from the API call. We’ll see completion handlers in Apple’s APIs like dataTaskWithRequest and they can be pretty handy in your own code.

The completion handler takes a chunk of code with 3 arguments:(NSData?, NSURLResponse?, NSError?) that returns nothing: Void. It’s a closure.

The completion handlers have to marked @escaping since they are executed some point after the enclosing function has been executed.

Explain the difference between atomic and nonatomic synthesized properties? 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 “synchronized”. 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). 17- What is Responder Chain ? ==> A ResponderChain is a hierarchy of objects that have the opportunity to respond to events received. ex. ?????? 18- What is Regular expressions ? ==> Regular expressions are special string patterns that describe how to search through a string. ex. regular expression for strong password, RE for correct mobile number

22- What is Functions ? Functions let us group a series of statements together to perform some task. Once a function is created, it can be reused over and over in your code. If you find yourself repeating statements in your code, then a function may be the answer to avoid that repetition.

Pro Tip, Good functions accept input and return output. Bad functions set global variables and rely on other functions to work.`

What’s the difference between not-running, inactive, active, background and suspended execution states?

    • Not running: The app has not been launched or was running but was terminated by the system.
  • Inactive: 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.
  • Active: The app is running in the foreground and is receiving events. This is the normal mode for foreground apps.
  • Background: 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.
  • Suspended: 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.

What is the difference between viewDidLoad and viewDidAppear? Which should you use to load data from a remote server to display in the view? viewDidLoad is called when the view is loaded, whether from a Xib file, storyboard or programmatically created in loadView. viewDidAppear is called every time the view is presented on the device. Which to use depends on the use case for your data. If the data is fairly static and not likely to change then it can be loaded in viewDidLoad and cached. However if the data changes regularly then using viewDidAppear to load it is better. In both situations, the data should be loaded asynchronously on a background thread to avoid blocking the UI. What considerations do you need when writing a UITableViewController which shows images downloaded from a remote server? This is a very common task in iOS and a good answer here can cover a whole host of knowledge. The important piece of information in the question is that the images are hosted remotely and they may take time to download, therefore when it asks for “considerations”, you should be talking about:

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

Other good answers will go on to talk about offline caching of the images, using placeholder images while the images are being downloaded. What is a protocol, and how do you define your own and when is it used? A protocol is similar to an interface from Java. It defines a list of required and optional methods that a class must/can implement if it adopts the protocol. Any class can implement a protocol and other classes can then send messages to that class based on the protocol methods without it knowing the type of the class. What is KVC and KVO? Give an example of using KVC to set a value. KVC stands for Key-Value Coding. It’s a mechanism by which an object’s properties can be accessed using string’s at runtime rather than having to statically know the property names at development time. KVO stands for Key-Value Observing and allows a controller or class to observe changes to a property value. Let’s say there is a property name on a class: @property (nonatomic, copy) NSString *name; We can access it using KVC: NSString *n = [object valueForKey:@”name”] And we can modify it’s value by sending it the message: [object setValue:@”Mary” forKey:@”name”] What is 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. If you get the opportunity to draw this one out, it’s worth doing to impress the interviewer: 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 visualization 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 color 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. How would you securely store private user data offline on a device? What other security best practices should be taken? Again there is no right answer to this, but it’s a great way to see how much a person has dug into iOS security. If you’re interviewing with a bank I’d almost definitely expect someone to know something about it, but all companies need to take security seriously, so here’s the ideal list of topics I’d expect to hear in an answer:

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

Other security best practices are:

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

With SSL pinning, we can refuse all connections except the ones with the designated server whose SSL certificate we’ve saved into our local bundle middle of the communication between the device U and router Rand it can eavesdrop or block it. IP forwarding is often used on the attacker’s device to keep the communication flowing seamlessly between the user’s device and router. Things are a bit more tricky when it comes toNSURLSession SSL pinning. There is no way to set an array of pinned certificates and cancel all responses that don’t match our local certificate automatically. We need to perform all checks manually to implement SSL pinning onNSURLSession. Alomfire there is one method ServerTrustPolicy.certificatesInBundle() method which returns all the certificates within the bundle. By default,AFNetworking will scan through your bundle and check for all “.cer” files, and add them to the manager.securityPolicy.pinnedCertificates array With the release of the iOS 9, the App Transport Security library was also introduced. By default, ATS denies all insecure connections which do not use at least the TLS 1.2 protocol. Autorelease pool The concept of an autorelease pool is simple, whenever an object instance is marked asautoreleased (for example NSString*str = [[[NSString alloc] initWithString:@”hello”] autorelease];), it will have a retain count of +1 at that moment in time, but at the end of the run loop, the pool is drained, and any object marked autorelease then has its retain count decremented. It’s a way of keeping an object around while you prepare whatever will retain it for itself. ViewLifeCycle loadView viewDidLoad viewWillAppear viewWillLayoutSubviews viewDidLayoutSubviews viewDidAppear Design Pattern viewController is tightly coupled because of viewLifecycle MVC, MVP(uikit independent mediator) , MVVM (mediator is VM and UIKITindependant) Viper – granularity in responsibilities is very good (view interactor presenter entity router) Test – setup and tear down  — xcassert function 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 then 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. What is AutoLayout? What does it mean when a constraint is “broken” by iOS? 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.

What is the difference between Synchronous & Asynchronous task ? Synchronous: waits until the task has completed Asynchronous: completes a task in background and can notify you when complete

What’s Code Coverage ? Code coverage is a tool that helps us to measure the value of our unit tests.

Security updates in iOS 10

App Transport Security (ATS) was introduced in iOS 9 as a built in utility for protecting network communications, namely connections which use the NSURLSession and NSURLConnection APIs. Out of the box, ATS enforces a TLS configuration with the following criteria:

    • Apps must connect to servers using the TLS 1.2 protocol
  • server must use HTTPS protocol

Important, by the end of 2016, Apple will enforce the use of ATS during App Store approval. It is therefore very important that engineering teams start to roadmap migration to securer HTTPS configurations as soon as possible. As a developer, you can still configure exceptions in the ATS configuration, but you will be required to provide a justification in the app store review as to why you require the exception. During the “What’s new in Security WWDC16 session”, Apple stated that one example use case for exceptions might be when you communicate with a 3rd party and don’t have control over their HTTPS configuration. Another example is when an Application communicates dynamically to various internet sites such as within a WebView. A 3rd example of an exception might be because the domain you want to communicate with does not offer Perfect Forward Secrecy.

ATS required by 2017

App Transport Security was introduced last year and by default blocks “unprotected” connections initiated by Apps, ie. connections that do not use HTTPS with the strongest TLS version and cipher suites. Because switching servers to the strongest TLS configuration takes time, Apple also allowed App developers to selectively disable ATS requirements by adding exemptions in the App’s Info.plist.

Purpose strings required

When built for iOS 10, an App will crash if it tries to request access for a data class that does not have a purpose string defined. Purpose string keys where introduced in iOS 6; there is one key defined for each type of privacy-sensitive data (contacts, camera, photo library, etc.). App developers can add these keys to the App’s Info.plist to provide a sentence that explains why the App needs access to the data; the explanation then gets displayed in the user-facing permission prompt: Not providing a purpose string will now crash the App when the permission prompt was going to be displayed. Apple made this change for two reasons:

    • It forces App developers to inform the user about the reason why the App needs access to the data.
  • It prevents third-party SDKs within the App from requesting access to data the App developers never intended to access in the first place.

Additionally, there are several new consent alerts in iOS 10, with a corresponding purpose string:

    • Media Library, for allowing access to Apple Music subscriber status and playlists.
  • Speech Recognition, for allowing audio files to be sent to Apple for speech transcription done on behalf of the App.
  • SiriKit, for allowing the App to receive Siri requests.
  • TV Provider information (tvOS only), for automatically logging the user into streaming Apps based on their cable subscription.
    1. https://www.codementor.io/mattgoldspink/ios-interview-tips-questions-answers-objective-c-du1088nfb

What is the difference between public and open? Why is it important to have both?

Open access imposes limitations on class inheritance. Classes declared with open level access can be subclassed by modules they are defined in, modules that import the module in which the class is defined, and class members as well. While this sounds similar to the public access level defined in Swift 2, there is a small difference. In Swift 3, the meaning of public access level means that classes declared public can only be subclassed in the module they are defined in. This includes public class members which can be overridden by subclasses defined int he module they are defined in.

Some classes of libraries and frameworks are not designed to be subclasses. For example, in the Core Data framework, Apple states that some methods of NSManagedObject should not be overridden. To prevent any unexpected behavior that may result from overriding those methods, Apple declares those methods public rather than open. As a result, those methods are not marked as open for developers to override.

What is waterfall methodology and Agile methodology? What are the differences between them?

Waterfall methodology is a sequential model for software development. It is separated into a sequence of pre-defined phases including feasibility, planning, design, build, test, production, and support.

On the other hand, Agile development methodology is a linear sequential apporach that provides flexibility for changing project requirements.

List of differences:

  • Waterfall model divides software development process into different phases while Agile segregates the project development lifecycle into sprints. This makes waterfall more rigid while agile allows for more flexibility
  • Waterfall model describes the software development life cycle as a single project while Agile considers it as a collection of many different projects; are iterations of different phases focusing on improving overall software quality with feedback from users and QA team.
  • Since waterfall is more rigid, development requirements need to be clearly established beforehand since there is little flexibility for changing once project development starts. Meanwhile, Agile allow changes to be made anytime along the project development process even after initial planning has been completed.
  • In Waterfall, the testing phase typically occurs after the build phase. In Agile, testing is often performed concurrently with programming or at least in the same iteration.
  • Waterfall is more of an interal process that does not involve user feedback. Agile tends to involve user participation more in order to improve customer satisfaction.
  • Waterfall model best fits projects that have a clearly defined set of requirements and where change to requirements is not expect. Agile fits more for projects where the requirements are expected to change and evolve.
  • Waterfall can exhibit a project mindset that focuses on completion of the project while Agile can allow for more focus on developing a product that satisfies customers.

What is the difference between a class and an object?

In the simplest sense, a class is a blueprint for an object. It describes the properties and behaviors common to any particular type of object. An object, on the other hand, is an instance of a class.

What is KVO?

KVO stands for Key-Value Observing. It allows a controller or class to observe when a property value changes.

Is it faster to iterate through an NSArray or an NSSet?

It depends. NSSet is faster to iterate through if the order of the items in the collection is not important. The reason is because NSSet uses hash values in order to find items while NSArray has to iterate through its entire contents to find a particular object.

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

  • Only download the image when the cell is scrolled into view (when cellForRowAtIndexPath is called)
  • Download 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, check if that cell is still in the view or whether it has been re-used by another piece of data. If the cell has been re-used, then the image should be discarded. Otherwise, it should be switched back to the main thread to change the image on the cell.
  • Can cache downloaded images if its not available in cache.

What is a protocol? How do you define your own protocol?

A protocol defines a list of required and optional methods for a class that adopts the protocol to implement. Any class is allowed to implement a protocol so that other classes can send message to it based on the protocol methods without knowing the type of class. An example of how a protocol is defined:

Memory Management

What is the difference between weak and strong?

First, objects are strong by default.

  • Strong means that the reference count will be increased and the reference to it will be maintained through the life of the object.
  • Weak, means that we are pointing to an object but not increasing its reference count. It’s often used when creating a parent child relationship. The parent has a strong reference to the child but the child only has a weak reference to the parent. (source)

Common instances of weak references are delegate properties and subview/controls of a view controller’s main view since those views are already strongly held by the main view

What is the difference strong, weaks, read only and copy ?

Strong means that the reference count will be increased and the reference to it will be maintained through the life of the object Weak, means that we are pointing to an object but not increasing its reference count. It’s often used when creating a parent child relationship. The parent has a strong reference to the child but the child only has a weak reference to the parent. Read only, we can set the property initially but then it can’t be changed. Copy, means that we’re copying the value of the object when it’s created. Also prevents its value from changing. 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.

Design Pattern

Why is design pattern very important ? 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. Most common Cocoa design patterns:

    • Creational: Singleton.
  • Structural: Decorator, Adapter, Facade.
  • Behavioral: Observer, and, Memento

25- What is Singleton Pattern ? The Singleton design pattern ensures that only one instance exists for a given class and that there’s a global access point to that instance. It usually uses lazy loading to create the single instance when it’s needed the first time.

What is the delegation pattern?

The delegation pattern is a powerful pattern used in building iOS applications. The basic idea is that one object will act on another object’s behalf or in coordination with another object. The delegating object typically keeps a reference to the other object (delegate) and sends a message to it at the appropriate time. It is important to note that they have a one to one relationship.

What is MVC?

MVC stands for Model-View-Controller. It is a software architecture pattern for implementing user interfaces.

MVC consists of three layers: the model, the view, and the controller.

  • The model layer is typically where the data resides (persistence, model objects, etc)
  • The view layer is typically where all the UI interface lies. Things like displaying buttons and numbers belong in the view layer. The view layer does not know anything about the model layer and vice versa.
  • The controller (view controller) is the layer that integrates the view layer and the model layer together.

What is MVVM?

MVVM stands for Model-View-ViewModel. It is a software architecture pattern for implementing user interfaces.

MVVM is an augmented version of MVC where the presentation logic is moved out of the controller and into the view model. The view model is responsible for handling most, if not all, of the view’s display logic.

A common occurence in MVC is where you have a massive-view-controller (some joke this is what MVC stands for). In order to shrink the size of your view controller and make the logic and readibility of your code easier to follow along, the MVVM will be used.

Design, View, Storyboard 

What is autolayout?

Auto Layout is used to dynamically calculate the size and position of views based on constraints.

16- What’s the difference between the frame and the bounds?

The frame of a UIView is the region relative to the superview it is contained within while the bounds of a UIView is the region relative to its own coordinate system..

What is the difference between viewDidLoad and viewDidAppear? Which should you use to load data from a remote server to display in the view?

viewDidLoad is only called when the view is loaded (after loadView is called). viewDidAppear, on the other hand, is called everytime the view appears on the device.

If the data is static for the most part, it can be loaded in viewDidLoad and cached. But if the data is dynamic and likely to change often, it is preferable to use viewDidAppear. In both instances, data should be loaded asynchronously on a background thread to avoid blocking the UI.

Thread management

What is the difference between synchronous and asynchronous task?

Synchronous tasks wait until the task has been completed while asynchronous tasks can run in the background and send a notification when the task is complete.

Explain the difference between Serial vs Concurrent

Tasks executed serially are executed one at a time while tasks that are executed concurrently may be executed at the same time.

What is GCD and how is it used?

GCD stands for Grand Central Dispatch.  It offers the following benefits

  • Improving your app’s responsiveness by helping to defer computationally expensive tasks and run them in the background.
  • Providing an easier concurrency model than locks and threads and helps to avoid concurrency bugs.
  • Potentially optimize your code with higher performance primitives for common patterns such as singletons.

In other words, GCD provides and manages queues of tasks in the iOS app. This is one of the most commonly used API to manage concurrent code and execute operations asynchronously. Network calls are often performed on a background thread while things like UI updates are executed on the main thread.

Unit testing, UI testing

Objective c –

Explain what is synthesized in Objective-C? Once you have declared the property in objective-C, you have to tell the compiler instantly by using synthesize directive. synthesize generates getter and setter methods for your property.

What is dynamic in Objective-C ? Dynamic for properties means that it setters and getters will be created manually and/or at runtime. We can use dynamic not only for NSManagedObject.

Why do we use synchronized ? synchronized guarantees that only one thread can be executing that code in the block at any given time.

Objective C :  1. What is @synthesize in Objective-C ? ==> synthesize generates getter and setter methods for your property.

2. What is @dynamic in Objective-C ? ==> We use dynamic for subclasses of NSManagedObject. @dynamic tells the compiler that getter and setters are implemented somewhere else.

3. Why don’t we use strong for enum property in Objective-C ? ==> Because enums aren’t objects, so we don’t specify strong or weak here.

What is the difference between category and extension in Objective-C?

A category and extension are similar in functionality where they can add additional instance and class methods to a class. However, an extension can only do so if the source code for the class being extended is available at compile time. This means that classes such as NSString cannot be extended. Instead, a category would be used to add additional methods to the NSString class


		
Advertisements