Skip to content

Instantly share code, notes, and snippets.

@digitallysavvy
Created December 3, 2019 20:00
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 digitallysavvy/9dd2299a12e4e45a7bff1339eb56a2af to your computer and use it in GitHub Desktop.
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
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