0

I am having an issue working with Data and SKSpriteNodes. Specifically, the conversion back from Data to SKSpriteNode. I have tried both methods of converting from data to something found here, specifically this line:

    let data:SKSpriteNode = Data(buffer: UnsafeBufferPointer(start: &value, count: 1))

and I just cannot seem to get it to work. It always comes up with this error though:

    Thread 1: EXC_BAD_ACCESS (code=1, address=0x600000123d40)

Any ideas what could be causing this? Am I trying to convert something too complex?

For reference, I am using iOS 10.3, Swift 3, and Xcode 8.3.2

HangarRash
  • 7,314
  • 5
  • 5
  • 32
Rocket6488
  • 103
  • 1
  • 9
  • Can you post the code relevant to the Data object and SKSpriteNode? – Chris Apr 13 '18 at 15:35
  • @Chris updated with the specific line – Rocket6488 Apr 13 '18 at 17:50
  • I don’t know much about pointers I’m afraid. Are you saving the data from a SKSpriteNode somewhere else? Why do you need to handle the SKSpriteNode this way? – Chris Apr 13 '18 at 19:17
  • For example, if you need to persist a sprite node’s data between app launches, you can use NSCoding (because the SKSpriteNode parent class SKNode inherits from NSObject). – Chris Apr 13 '18 at 19:20
  • I'm using this for multipeer connectivity, I've seen its best to send things as data through this – Rocket6488 Apr 13 '18 at 21:55

0 Answers0