iOS General Flashcards
(166 cards)
What states can a running UIApplication be in?
UIApplicationState: Active, Inactive, and Background
What classes would you use to encode and decode NSCoding compliant classes into a format that can be stored in a file?
NSKeyedArchiver and NSKeyedUnarchiver
What is the C-based API for concurrent programming?
Grand Central Dispatch
What is the object oriented API for concurrent programming?
NSOperation (and NSOperationQueue)
How many view controllers does a UISplitViewController manage?
Either one (if it is collapsed) or two
What is the main limitation when using Objective C categories?
A category cannot define new instance variables or add new storage to a class
Name a common cause of exc_bad_access
Trying to access an object that has been released (or not initialized)
Name a common way of tracking down the cause of exc_bad_access
Enable zombie objects within the Xcode scheme
What do you need to do in a project to use Swift from Objective C?
Xcode creates a ‘generated header’ automatically, you just need to import it
(But note that classes need to extend NSObject or be marked with the @objc attribute in order to be available to Objective C - and of course don’t expose things like tuples, that only exist for Swift)
What do you need to do in a project to use Objective C from Swift?
Create a ‘bridging header’ that imports the required code
Does a delegating object maintain a strong or weak reference to its delegate?
Weak
What is the Swift equivalent of Objective C categories?
Extensions
What is a workaround for categories not being able to add new instance variables to a class?
Use ‘Associated Objects’ via objc_[set,get]AssociatedObject
Which Foundation collection would you use for frequent containsObject: tests?
NSSet (it’ll be faster than NSArray)
What is required of classes that are to be used as dictionary keys?
Provide answers for both Objective C and Swift
Objective C: they must conform to NSCopying and implement copyWithZone:
Swift: they must conform to Hashable and implement var hashValue: Int { get }
What is a key requirement when implementing the isEqual: method?
If two objects are equal, they must have the same hash value
When would you use __block?
Normally variables are copied when used inside a block and so changes are not reflected outside of the block - but when using __block, such changes are visible outside too
What is a retain cycle?
A retain cycle is a situation when object A retains object B, and object B retains object A at the same time (there could be longer chains of objects too)
Explain messages vs methods in Objective C
Sending messages is more dynamic. Sending a message usually results in the corresponding method being called - but it doesn’t have to. Objects don’t have to respond to messages. Messages that an object responds to don’t have to be known at compile time
Name a way to add visual effects (such as blur or vibrancy) to a user interface
Using a UIVisualEffectView in conjunction with UIBlurEffect or UIVibrancyEffect
What’s the difference between UIModalPresentationFullScreen and UIModalPresentationOverFullScreen?
FullScreen removes the views beneath the presented view controller, whereas OverFullScreen does not (and hence they may still be visible in some form)
When would you use NSValue?
When you need to wrap scalar types - e.g. ints, floats, chars, pointers, structs, object id references - in an object (so that they can be added to a collection, for example)
When is a view controller’s preferredContentSize generally used?
When displaying the view controller’s content in a popover
How do you determine which view controller presented a view controller (if any)?
Use the UIViewController property presentingViewController





