Skip to content

Instantly share code, notes, and snippets.

@godrm
Created October 12, 2020 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save godrm/8e1bed5545cd963075dc3cf7755fb2ae to your computer and use it in GitHub Desktop.
Save godrm/8e1bed5545cd963075dc3cf7755fb2ae to your computer and use it in GitHub Desktop.
import Cocoa
var str = "Hello, playground"
let ptr = UnsafeRawPointer(str)
let origin = CGPoint(x: 0, y: 0)
var other = origin
other.x += 10
var another = origin
another.y += 5
var addressO = UnsafeMutablePointer<CGPoint>(&other)
var addressA = UnsafeMutablePointer<CGPoint>(&another)
func swapPoint(pointA : inout CGPoint, pointB : inout CGPoint) {
let temp = pointA
pointA = pointB
pointB = temp
}
swapPoint(pointA: &other, pointB: &another)
var addressO1 = UnsafeMutablePointer<CGPoint>(&other)
var addressA2 = UnsafeMutablePointer<CGPoint>(&another)
print(other, another)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment