문제

I'm working on an iOS game and I'm using the NSCoding protocol to save my levels in my editor and to load them in game. I was wondering if it was possible to somehow reuse an NSKeyedUnarchiver after it's been used to load the level. For instance when the player wan't to restart the level. I can't simply create and load a new instance of the level, because I want to keep the same objects, just reset their properties.

도움이 되었습니까?

해결책

You can re-use the data, which is passed down to decoder. You cannot "reset" the existing objects to initial state, though.

While you can do this on your own, I'd suggest to just invalidate the whole tree of objects and re-load them from possibly cached data.

That surely depends on the number of objects, but if you have enough of them for the process to be visibly slow, I believe you have lots of other more important optimisations to do.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top