Swift Developer News - Hacking with Swift News, tips, and tutorials from Hacking with Swift https://www.hackingwithswift.com/articles/rss (c)2017 Paul Hudson https://www.hackingwithswift.com/favicon-96x96.png Swift Developer News - Hacking with Swift https://www.hackingwithswift.com/articles/rss How to read Apple’s developer documentation https://www.hackingwithswift.com/articles/167/how-to-read-apples-developer-documentation https://www.hackingwithswift.com/articles/167/how-to-read-apples-developer-documentation Get the most from our primary reference to UIKit and more Fri, 11 Jan 2019 23:47:24 +0000 To many people this article will sound strange, because we’re used to the way Apple’s API documentation works and so we’re mentally tuned to finding what we want quickly.

But here’s a fun fact: one of the most popular article requests I had last year to help folks actually read Apple’s code documentation. How do you find the iOS APIs you’re looking for, how do you navigate through all the material to find what you actually want, and how do you dig deep to get an understanding of why things work the way they do?

So, if you’ve ever needed help to understand Apple’s developer documentation, first I want you to know that you’re not alone – many, many people struggle with it. But second, I hope this article will help: I’ll try my best to explain how it’s structured, what it’s good for (and not so good for), and how I use it.

More importantly, I’ll show you where experienced developers look for extra information that is often even more valuable than Apple’s online documentation.

“What is it?” vs “How do you use it?”

Any written API documentation usually takes one of five forms:

  1. Interface code that shows what something is: method names and parameter, property names and types, and similar, with a little text describing what it’s supposed to do.
  2. Text description of the API describing what it’s supposed to do as well as general guidance of use cases.
  3. Sample code that uses the API extensively to make something useful.
  4. Code snippets showing the basics of how to use an API.
  5. A cookbook solving common problems: how to do X, how to do Y, and how to do Z, and so on.

Very roughly, Apple does a lot of the first, a fair amount of the second and third, a small amount of the fourth, and almost none of the fifth.

So, if you’re looking for specific examples of “how to do X with Y” you’re better off starting with my Swift Knowledge Base – that’s exactly what it’s there for.

Understanding the problem Apple’s docu...

Xcode tips and tricks – part one https://www.hackingwithswift.com/articles/166/xcode-tips-and-tricks-part-one https://www.hackingwithswift.com/articles/166/xcode-tips-and-tricks-part-one Learn useful Xcode features with short videos. Thu, 10 Jan 2019 17:29:22 +0000 Xcode is a fantastic tool, but it’s so big it can be hard to keep track of all the things it can do. To help resolve that situation, below you can find a selection of Xcode tips and tricks that you might find useful. If you have some favorite Xcode tips of your own, let me know on Twitter!

1. Regex searching

Xcode lets you search through your project using regular expressions. To try it out, go to the Find navigator, click Text, then choose Regular Expression. Now you can search and replace code using whatever regex you like.

2. Faster Testing

When using TDD you can work more quickly by running a subset of tests – press ⌃⌥⌘G to re-run only your last test, or ⌘-click several tests to run only them.

3. Layout stress testing

When using IB in the assistant editor, change Automatic to Preview then change the language from English to Double-Length Pseudolanguage. This will cause every word in your UI to be repeated, letting you make sure it all fits.

4. Opening Xcode

If you’re in a folder that has both a workspace and a project, use “xed .” to open the workspace in Xcode. If there were only a project, that would have been opened instead.