Pointer in UnSafe Swift
Contents
Pointers
Unsafe Swift pointers use a predictable naming scheme:
Unsafe [Mutable][Raw][Buffer]Pointer[<T>]
Explain:
Pointers are just memory addresses.
Direct memory access is Unsafe.
Mutable means you can write to it.
Raw means it points to a blob of bytes.
Buffer means that is works like a collection.
Generic [<T>] pointers are typed.
Working with Pointers
C Pointer | Swift Type |
---|---|
int * | UnsaftMutablePointer |
const int * | UnsafePointer |
NSDate ** | AutoreleasingUnsafeMutablePointer |
struct UnknowType * | OpaquePointer |
void * | UnsafeMutableRawPointer |
const void * | UnsafeRawPointer |
Explain: see here
Pointer Safety
Safely manage pointers in Swift