What are the best resources for learning iOS development?

来源:互联网 发布:淘宝专业版店铺装修 编辑:程序博客网 时间:2024/04/29 19:00

What are the best resources for learning iOS development?

Article Source: https://www.quora.com/What-are-the-best-resources-for-learning-iOS-development?redirected_qid=1992810

Not interested in a 3rd party workaround. I'm looking to learn Swift, Objective-C, and Cocoa. My programming background is web-based.
Question merged
You were redirected because this question was merged with What are the best new resources for learning iOS development in 2014?
Richard Henry
Richard Henry, Mobile Product Designer at Quora
I learned everything I needed to know initially about iOS development from the Stanford CS 193P videos, and the videos from the most recent WWDC.

Tips for the CS 193P videos:
  • Just watch the first 2-3 videos without building anything yourself
  • Then start over and follow along by building a simple hobby app that is more fun than the boring app the professor is building
  • Keep watching the videos in order as you have time, but start skipping around to the parts that contain what you need to know
  • Download slides as a PDF whenever you can, makes it easier to jump around and use code samples
  • You don't need to be drawing and using drawRect: as much as the professor seems to want to, using subviews or sublayers to create simple shapes will probably be a lot easier at first
  • You probably need to watch the first 7 before you start to get a real grip on the key tools that you will need to build an app, but you can certainly start hacking on something much more quickly

Tips for the WWDC videos:
  • Expect most of them to not be useful from an initial learning perspective
  • Some are really useful though because of the sample code in the slides, I remember the Core Animation video and slides being especially helpful
  • Understanding UIKit Rendering from 2011 is really useful for understanding how to work with views, layers, layout and rendering
  • So are the UIScrollView sessions, maybe start with 2011 and work your way up to today, also the most entertaining WWDC session by far
  • Also take a look at Apple's sample code whenever you're stuck on a particular API for usage
  • Remember to option click a method name in Xcode to see it's arguments or get to the docs page

Expect these parts of iOS development to be the hardest:
  • Understanding protocols and delegates (don't try to gloss over this section of the CS 193P videos or you will be so confused later)
  • Figuring out where to put code (I'll post a few general tips below)
  • Memory management (with ARC this is fairly simple now, just try to get an understanding of the difference between strong/weak references, be a little wary of blocks, and eventually learn how to use the allocations/leaks instruments)

Where to Put Code


Some really general tips on code organization:
  • Expect your app to be a sort of tree of references from the AppDelegate to one class instance (like a main UIViewController), which will have references to other class instances (like a UIView and other UIViewControllers), and so on
  • In a UIViewController, expect to do most of your setup in viewDidLoad
  • At first, you can probably do most of what you need to do without subclassing UIViewat all, unless you need to use drawRect: or override other UIView methods, using a view instead of a view controller is mostly organizational
  • In a UIView, do most of your setup (i.e. creating subviews) in init (save drawRect:for actual drawing only)
  • If you're trying to create a more complex layout, don't forget about layoutSubviewsfor adjusting subview frames and so on
  • For now, bias to using properties instead of ivars, you can create a private @interface if you don't want to expose a property to other classes
  • Read the documentation for UIViewController's viewWillAppear, viewDidAppear, viewWillDisappear, and viewDidDisappear (all pretty succinct and once you start to do anything remotely complex you will need to override these methods)

Persisting Data


You should consider NSUserDefaults a good alternative to Core Data or SQLite if all you want to do is persist a few objects and don't need to query them (i.e. give me objects where…). This is what the pros do, and user defaults has the upside of being much easier to understand as a beginner. It's basically a persistent dictionary, or a key value store. For pure data retrieval, Core Data and SQLite are not faster than user defaults — they are all reading from disk.

"The Best Way"


Once you get to the point where you're starting to care about code style, or if you're just wondering how an experienced programmer might do something, I like the NYTimes Objective-C Style Guide.

The Future


As you progress you should try to get into a habit of skimming at least the high level documentation for every method you're using or overriding. Sometimes the documentation will make you aware of surprising side effects, or alternative ways of doing the same thing that might be better for your use case. This is the best way to become really familiar with Foundation and UIKit.

Once you're even further along on your iOS development journey, you might enjoy reading NSHipster — a pretty entertaining blog that documents useful but overlooked APIs or Obj-C features.
1 0
原创粉丝点击