This course is available as part of the Professional subscription. To learn more click here

Advanced Swift: Unsafe Memory Access

May 21 2019 · Video Course (24 mins) · Advanced

Did you know you can call C-malloc straight from Swift? Swift lets access the machine at its lowest level. This course will show you how.

4.6/5 5 Ratings


  • Swift 5, iOS 12, Xcode 10


2:41 Free

Swift is safe by default. Sometimes you may need to forgo this safety for extra performance or to interact with an unsafe language such as C.


When you are working with with unsafe code, you need to concern yourself with the size of objects in memory.


In this video we will explore the fundamentals of unsafe memory access, and learn about the types involved.


When you are using memory unsafely, the compiler no longer provides guarantees and you must follow basic rules to avoid undefined behavior.


It's time for a challenge! See if you can use your unsafe Swift skills to wrap a data compression C-API.




Unsafe Swift lets you access raw memory. While it requires extra diligence, you can keep such places small and isolated.


Next course in this Learning Path

Who is this for?

This course is for developers interested in getting a deeper understanding of the Swift language. It expects you to be comfortable with the basic syntax of Swift and to have perhaps written an app or two. You should be familiar with basic types in the Swift standard library.

Covered concepts

This course focuses on:

  • Best practices for memory safety
  • Pointer types
  • Unsafe Swift and why not to use it