Created
October 12, 2020 06:55
-
-
Save godrm/8e1bed5545cd963075dc3cf7755fb2ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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