IOS Interview
IOS Interview
IOS - 12.1
What is delegate
Delegate is an object that handles the events happening on an object. To do
that delegate has to follow a protocol specifying the task it is going to handle
Delegat
The delegation is a commonly used pattern in object-oriented programming. It
is a situation where an object, instead of performing a tasks itself, delegates
that task to another, helper object. The helper object is called the delegate
A delegate allows one object to send messages to another object when an
event happens
A delegate is just an object that another object sends messages to when
certain things happen, so that the delegate can handle app-speci c details
the original object wasn't designed for. It's a way of customising behaviour
without subclassing
They are never retained
fi
.
What is @synthesize
We use @synthesize to generate getters and setters automatically from
compiler. We declare properties and then generate getter and setter method
by using @synthesize
Atomic
It is the default behaviour. If an object is declared as atomic then it becomes
thread-safe. Thread-safe means, at a time only one thread of a particular
instance of that class can have the control over that object
Nonatomic
It is not thread-safe. You can use the nonatomic property attribute to specify
that synthesised accessors simply set or return a value directly, with no
guarantees about what happens if that same value is accessed
simultaneously from different threads. For this reason, it’s faster to access a
nonatomic property than an atomic one
Retain
is required when the attribute is a pointer to an object.The setter method will
increase retain count of the object, so that it will occupy memory in
autorelease pool
t
fi
?
fi
.
fi
?
copy:
If you use copy, you can't use retain. Using copy instance of the class will
contain its own copy. Even if a mutable string is set and subsequently
changed, the instance captures whatever value it has at the time it is set. No
setter and getter methods will be synthesised
Readonly
If you don't want to allow the property to be changed via setter method, you
can declare the property readonly
Readwrite
is the default behaviour. You don't need to specify readwrite attribute
explicitly
Assign
will generate a setter which assigns the value to the instance variable
directly, rather than copying or retaining it. This is best for primitive types like
NSInteger and CGFloat, or objects you don't directly own, such as delegates
Strong:
Strong is required when the attribute is a pointer to an object.The setter
method will increase retain count of the object, so that it will occupy memory
in autorelease poo
Unsafe_unretained
There are a few classes in Cocoa and Cocoa Touch that don’t yet support
weak references, which means you can’t declare a weak property or weak
local variable to keep track of them. These classes include NSTextView,
NSFont and NSColorSpace,etc. If you need to use a weak reference to one
of these classes, you must use an unsafe reference. An unsafe reference is
similar to a weak reference in that it doesn’t keep its related object alive, but it
won’t be set to nil if the destination object is deallocated
fi
.
Core Data is not a relational database, you can see Core data as a wrapper
around Sqlite although core data is quite simpler as compared to Sqlite but it
does not offer some of the functionality that Sqlite can offer and vice vers
Coco
Cocoa is the application framework for developing applications in Mac OS X
Cocoa is commonly referred to as the combination of the Foundation
and AppKit frameworks,
Cocoa Touc
Cocoa Touch is the application framework for iPhone,iPad and iPod
Touch
Cocoa Touch is the combination of the Foundation and UIKit
framework
What is ARC
ARC is a compiler-level feature that simpli es the process of managing the
lifetimes of Objective-C objects. Instead of you having to remember when to
retain or release an object, ARC evaluates the lifetime requirements of your
objects and automatically inserts the appropriate method calls at compile
time
Inactive state
.
fi
?
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
brie y 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 brie y 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
fl
.
fi
?
If you use it (with the SQLite store type), especially in conjunction with
NSFetchedResultsController, you should get better performance than you
could get with SQLite on your own
Apple has worked hard to make Core Data perform well on the iPhone. My
application switched from SQLite w/ FMDB to Core Data and it is now faster
and more stable with less code
.