NEW: Learn SwiftUI with my free YouTube video series! >>

Swift Knowledge Base

Free example code you can take and re-use in your own projects.

This is the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions, all written for Swift 5. You can search all questions by typing below, or browse a category the old-fashioned way if that's your thing.

If you like this, you should check out my free Swift tutorial series.

Browse by category…

Frequently asked questions

Why is this better than just using Google?

Swift is a language that has changed a lot since its launch, and continues to change with every new Xcode release. This frequently makes it hard to find answers to common questions, because what worked a year ago is today probably incompatible! So, I made this as a one-stop-shop for 600 of the most common questions I get asked about Swift, and I made sure the answers were fully updated for Swift 5.0. You don't need trial and error: everything is written for Swift 5.0.


How is this different from Hacking with Swift?

Hacking with Swift is a tutorial series that is designed to help you learn Swift while you build full projects – it's not designed to answer simple questions in your own projects. About 50% of this knowledge base is lifted directly from Hacking with Swift, then trimmed down so you get just the facts, and updated for Swift 5.0.


Why are some answers so brief?

I tried to make every answer brief, because when you're looking for answers you don't want to read waffle. If you're looking for answers and only answers, this is the right place. If you're looking for explanation and elaboration, you should read the main Hacking with Swift tutorial series.


Why are some answers so easy?

I get a lot of questions from readers every day, some on Disqus, some on Twitter, and some by email. I've tried to make the answers you see here representative of the questions I get, and it's true: there is a huge range of skills out there. So, some questions are easy, some are hard, and some are in between – and that's OK.


Why is there nothing about SomeAwesomeClass?

Like I said, these questions were put together by summarising nine months of messages from readers, so if I missed something off it's probably because I wasn't asked very often or at all. If it's something you feel very strongly about, send me a tweet @twostraws.


Browsing by category sucks – why do you suck so much?

I agree, which is why I put in the search box. Please use it!


Buy Testing Swift Buy Practical iOS 12 Buy Pro Swift Buy Swift Design Patterns Buy Swift Coding Challenges Buy Server-Side Swift (Vapor Edition) Buy Server-Side Swift (Kitura Edition) Buy Hacking with macOS Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with Swift Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let me know!

Click here to visit the Hacking with Swift store >>