Advanced Swift: Unsafe Memory Access

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. By Ray Fix.

Leave a rating/review
Save for later
Comments
Share

Learning path

This is part of the Advanced Swift learning path. View 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

01
Toggle description

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.

Toggle description

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

Toggle description

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

Toggle description

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

Toggle description

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

Conclusion 1:51
Toggle description

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

Up next

Multiple Domains
Advanced Swift: Error Handling
Production code is all about handling errors: programming errors, user input errors, asynchronous errors. ... more

Instructors

Contributors

Ray Fix

Instructor

JORGE R. MOUKEL

Tech Editor

Over 300 content creators. Join our team.