General programming questions
- OOP basics: what is a class, interface, instance variable, methods, static (class) methods vs instance methods. Header vs implementation files
- What is a process, thread
- design patterns and principles
- blackbox vs whitebox testing differences? unit testing? integration testing? regression testing?
- what is continuous integration?
- difference between stack/heap
What do you need to be able to develop for iOS
MAC OS X, XCode, Developer Profile …
Define basic OOP concepts and the keywords in ObjC
interface, implementation, inheritance, property, protocol, etc…
Application lifecycle; What kind of states an application can have? Which general methods are called?
States: not running, inactive, active, background or suspended. There are methods and notifications to handle the transitions.
What is a property? How can you create one? What is the benefits to use properties?
@property, (auto)synthesize; getter/setter method (also send KVO notifications). Hides the iVars (safety and flexibility)
private/public – no protected. anyone can call a private
What is a protocol? Protocol declaration and implementation, optional declaration
How to check an optional protocol method existence on an object?
+ and - methods
class vs instance methods
What about multiple class inheritance
technically none …
How to add a method to a class (extend) without the source of the class and without recompiling the class
what are categories?
Difference between extensions () and (named) categories?
Benefits of extension category?
private property declaration, compile time method check.
Can you re-declare a property in subclass or extension?
YES. If you declare a property in one class as readonly, you can redeclare it as readwrite in a class extension, in a protocol, or in a subclass.Limitations of- and problems with categories?
Cannot override an existing method and call it in the extension method
What are formal and informal protocols?
Formal are the real protocols, informal are categories on NSObject (with optional methods)
How to declare protected-like methods (accessible only for some dedicated classes)?
Separate header file with (named) category, and include it in other class
What is a designated initializer, what is the pattern for the initializers and why ( if (self = [super ...] ) )
Property modifiers and the meaning
nonatomic/atomic, assign/retain/copy/readonly vs strong/weak/unsafe_unretained, getter=, setter=
How can one object inform an other that something happened?
only one (subscribing): target-action, delegate, block. Unlimited: notification
What is a delegate, how to create one, and use one<”div” class="collapseomatic " id="id8608" tabindex="" title="”When" >”When”div”>
Delegate rule: how to handle ownership and why
never retain! circular reference problem
Delegate vs target/action vs block vs NSNotification
Problem with blocks usage
recursive calls (on fail restart the method which expects the same block) problematic and only one ‘method’ can be called – delegate can have more methods. Solution to recursive calls: put the method to a __block local variable, so it can call/reference itself
What is a selector? How to call a selector?
What is the difference between the dot notation and using the square brackets
What is KVO - where/how/why to use - how does it work - how to implement properly a KVO compliant property
What is KVC - where/how/why to use
What is fast enumeration
check a class is compatible with a baseclass and a given class
isKindOfClass, isMemberOfClass, isSubclassOfClass
NSObject, NSProxy, id
can be any object, but no native/primitive type
how to make an object from a native/primitive type (boxing)?
How methods are called? When the exact pointer is turns out
message sending, runtime
What is Notifications, NSNotificationCenter, local notification, push notification in general?
What's necessary for the localization
Localization strings files, NSLocalizedString
How can you support a language which is not supported by the OS?
put to strings file and load from the specified table (NSBundle localizedStringForKey:value:table:)
AccessibilityLabel, accessibilityValue etc
Background thread not to block UI. Use queues instead of threads
basic memory management topics: ownership
retain/release/autorelease, ARC vs MRC
what is retainCount, when to use
reference count to the object. never use (helps for debug)- cannot access in ARC
autorelease pool usage
what is a memory warning, how do we respond to it
ARC vs MRC
Can you use a library in ARC which were written using MRC?
Reflection? Introspection? is there anything in objc and cocoa?
YES. Advanced: objc_* class_*, object_* methods
Threading possibilities - starting background tasks: nsthread vs nsoperationqueue vs GCD queues vs performselectorafterdelay
What is a deadlock, how can it happen?
How to make a code snippet thread safe?
How can you synchronize threads (and with timeout)?
When and why to create thread (with one of the thread technics)?
When to start a real NSThread?
Very rare – use alternate instead
What is the first thing to do on a thread and why?
Create autorelease pool
What is GCD? Benefits, general behavior?
OS handles threads – very optimal
When to use dispatch queues
As often as possible when a thread necessary
Main dispatch queue types: main, background, serial - when to use which and why
Benefit of NSOperationQueues
priorities, cancellations: but you have to implement cancellation, you can implement the same with the other solutions as well…
What is a runloop, where it is very commonly used
What happens when you create a block?
created on the stack, copy moves to the heap. copies the context’s variables
Can you modify a variable out of the scope of a block?
YES, __block variables
difference between dispatch_sync and dispatch_async
When to use NSUrlRequest download methods and when to use delegate implementation?
What you should listen when download something from the internet
NSURLConnection, NSRequest. Download in background. You should present in the UI: activity indicator in status bar or in separate view
What is the difference between synchronous and asynchronous requests
Base classes and general description
UIResponder, UIView, UIControl
How the event handling happens?
Difference between UIWindow and UIView
Can we have more UIWindows in iOS?
Yes, but rare – UIAlertView is a separate window
Difference between bounds, frame of a view
What's very important designing UIs (views)?
different resolutions, horizontal-vertical orientation, iOS7 sucks
Difference between points and pixels
What is the responder chain?
becomeFirstResponder ??? routing of touch messages – hittest, views passes to viewcontrollers then window ???
What is IBOutlet and IBAction? How do you use them?
Basic tableview how to: datasource and delegate implementation
Drawbacks of UITableViews
only vertical… ???
Benefits of collections views
What is very important updating the UI in a multithreaded application? How can you do that?
update only on main thread/ main queue
what to do when the keyboard appears and hides some parts of the UI that are important - logic implementation
scrollview and keyboard notification handling
Why should we release the outlets in viewDidUnload in MRC? What about ARC?
Difference in Xib/storyboard vs nib?
xib and storyboard are xml but nib is binary – resource compiling”]
push, modal, custom, (embed? in segue)
how can we present new view controllers?
modal vs push
tabbar vs toolbar vs navigationbar: when to use which, can you combine them?<”div” class="collapseomatic " id="id8710" tabindex="" title="”UI" >”UI”div”>
use public properties, use appearance
UIAppearance basics, difference between setting through appearance proxy and instance
- appearance proxy: modifying a property on the proxy object=all instances gets the value;
- modifying a property on an instance: just the instance gets modified; now can change more than previously. UI_APPEARANCE_SELECTOR marks these properties.
For example, to modify the bar tint color for all UINavigationBar instances: [[UINavigationBar appearance] setBarTintColor:myColor] VS [(UINavigationBar *)aUINavigationBar setBarTintColor:myColor]
what is CoreData and what do we use it for
is CoreData == sqlite or some wrapper?
on iOS it supports binary database, SQLite, in memory – on MAC it supports xml as well
what types of stores does core data support
What is the minimum necessary classes and relationship between them?
NSPersistentStore, NSPersitentStoreCoordinator, NSManagedObjectModel, NSManagedObjectContext
Can the NSPersistentStoreCoordinator have more persistent stores?
YES – but cannot handle if the same class is in different stores – can handle if separate or related classes are in different stores
What is a managed object context
What about multi-threading and core data usage
contexts aren’t thread safe ??? after iOS5?
What is an NSManagedObjectId
unique id, shareable; we can save it for later if the application was stopped
What is lazy loading, how does this relate to core data, situations when this can be handy
How to read only a few attributes of an entity
What is a fetchedresultcontroller
How to synchronize contexts
How could one simulate an NSManagedObject (dynamic properties)
What is an actual class in ObjectiveC
What is the isa member
How to make a static library optional?
runtime class and method checks – NSClassFromString, respondsToSelector etc
How to correctly implement a retaining setter property
retain the parameter before release the old saved value
How to declare the properties to work the same in MRC and ARC?
strong=retain, unsafe_unreatained=assign etc ???
What happens if you add your just created object to a mutable array, and you release your object
What happens with the objects if the array is released
What happens if you remove the object from the array/dict, and you try to use it
Crash. you should get it first, retain, than remove from the array/dict
Garbage collection on iPhone
– none, similar: ARC, (autoreleasepool)
The circular reference problem with delegates
delegates being usually saved with assign rather then retain. Exception: NSURLConnection
What happens when we invoke a method on a nil pointer?
Nothing. Well known solution in ObjC
What happens when we call a method on an object which doesn't exists?
Does KVO works with iVars?
NO. Why? observation messages is sent by the properties
Does KVC works with iVars?
When it is mandatory to synthesize properties
if declared in protocols
What to do in a situation when a class not necessarily implement a method from a protocol
This could happen when the method is optional, check with respondsToSelector
Difference between nil and Nil and NULL???
How does proxy-ing work ???
How to call a method on an 'unknown' typed object?
performSelector vs objc_msgSend vs etc…???
How to call a selector with more than 2 parameters?
NSInvocation, or declare block instead if possible, or objc_msgSend, or simply use object as ‘id’ and call the selector as simple method (creates warnings)
How to cancel a block?
How NSOperation cancellation works?
you have to implement in your code by listening the cancelled flag
Can we/should we invoke (public) instance methods in an initializer and the dealloc? what about properties?
subclass can override (don’t know what will happen, properties fires KVC notifications=don’t know what happens when one listens)
Can we use our own objects as key in a dictionary?
No. What to do to solve the problem – implement NSCopying
The difference between a shallow and a deep copy
What can't we put into an array or dictionary?
nil, objects not implementing NSCopying
How can we put nil it into dictionary/array?
How to get the current language of the device?
[NSLocale currentLocale] wrong it gives the Region!!!: use [NSLocale preferredLanguages];