Apple's sample code is terrible. I've always assumed it is written by interns because it is generally bug ridden and often not the right way to do something.
Do you mean the code examples in articles or the projects that you can download? Because I haven't looked at their downloadable samples in quite some time, but their docs always seem alright to me.
Both, in my experience. The downloadable code is usually a rush job and has all sorts of sloppiness and missed edge cases. The code in the docs is usually cleaner (because it's just excerpts), but doesn't always get updated when APIs change.