Created
December 3, 2019 20:00
-
-
Save digitallysavvy/9dd2299a12e4e45a7bff1339eb56a2af to your computer and use it in GitHub Desktop.
A snippet showing how to decode the data and store it in an array within the ARSupportBroadcastViewController
This file contains 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
default: | |
if debug { | |
print("touch points msg recieved") | |
} | |
// convert data string into an array -- using given pattern as delimeter | |
let arrayOfPoints = dataAsString.components(separatedBy: "), (") | |
if debug { | |
print("arrayOfPoints: \(arrayOfPoints)") | |
} | |
for pointString in arrayOfPoints { | |
let pointArray: [String] = pointString.components(separatedBy: ", ") | |
// make sure we have 2 points and convert them from String to number | |
if pointArray.count == 2, let x = NumberFormatter().number(from: pointArray[0]), let y = NumberFormatter().number(from: pointArray[1]) { | |
let remotePoint: CGPoint = CGPoint(x: CGFloat(truncating: x), y: CGFloat(truncating: y)) | |
self.remotePoints.append(remotePoint) | |
if debug { | |
print("POINT - \(pointString)") | |
print("CGPOINT: \(remotePoint)") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment