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/5 2 Ratings

Version

  • Swift 5, iOS 12, Xcode 10

Introduction

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.
1
When you are working with with unsafe code, you need to concern yourself with the size of objects in memory.
2
In this video we will explore the fundamentals of unsafe memory access, and learn about the types involved.
3
When you are using memory unsafely, the compiler no longer provides guarantees and you must follow basic rules to avoid undefined behavior.
4
It's time for a challenge! See if you can use your unsafe Swift skills to wrap a data compression C-API.
5

Conclusion

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

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

Contributors

Comments