Topics
-
“Deprecated”
-
Storyboard or programmatic views
-
Mystery letters next to file names
-
Designated initializer
-
_instanceVariables in inits and setters
Question: When I look at Storyboard segues, there’s the word deprecated next to push segues. What does deprecated mean?
Answer: Apple will not be phasing out that features soon in the next release. It looks like they’re replaced the push segue with a show segue.
Question: Should I be learning to use the storyboard or learning to make views programmatically?
Answer: It depends on the usage. Storyboard is great for building views quickly and with little code. I was told that one major drawback is that it’s almost impossible to merge conflicts on storyboards. This means that when another programming changing the same view, one person’s changes will be lost. This can be mitigated by creating xib files for each classes and one owner per class. Storyboard tutorial for iOS 7.
Question: What are those A, C and M letters next to file names on the project Navigator in Xcode.
Answer: Those are the git version control symbols. A for added. C for conflict. M for modified. More here.
Question: Do I make the base initializer(init) or the custom initializer (initWithName:Birthday:Hometown:) make the designated initializer?
Answer: Use the custom initializer as the dedicated initializer. For the base initializer, use the dedicated initializer and pass in default values. More here. It saves repeated code and makes there one point of failure.
Question: Why should I use _instanceVariable in the init and setter methods instead of self.instanceVariable? I thought that we were supposed to always call methods.
Answer: For one, using self.instanceVariable in the setter will get an infinite loop because it will keep calling setInstanceVariable. There is a thing called key value observing (KVO) (awesome tutorial), which notices whenever the setter method is called for a property. In the init method, we don’t always want other people to know that we’re setting the property value.