SKSpriteNode pools in iOS 8 seem to be allocated for overlapping memory

Maybe I missed something. But my current app in appstore works in iOS 7, but in iOS 8 it completely fails because it will not create a pre-allocated sprite pool. It seems that they are written at the same address, unless sprites have special properties.

In iOS 7, the following code creates a set of 4 unique objects. In iOS 8, the same code creates a collection with only one object:

NSMutableSet *aSet = [NSMutableSet set]; SKColor *sameColor = [SKColor redColor]; CGSize sameSize = CGSizeMake(10, 10); for (int i = 0; i < 4; i++) { //allocate a brand new sprite SKSpriteNode *thisSprite1 = [[SKSpriteNode alloc] initWithColor:sameColor size:sameSize]; [aSet addObject:thisSprite1]; } NSLog(@"aSet Count: %i", aSet.count); 

iOS8 Result:

2014-09-09 15: 06: 43.065 MSM [383: 27490] aSet Count: 1

I've gone crazy? Surprisingly, almost all of my application is based on this concept of code, repeated over and over again. If I do the same, but use something like NSObject , the problem disappears, so this is a new change for SKSprite . I know that I can get around this with some crazy things, but it is a huge pain, since I should not have done this, and I was hoping to avoid sending another version.

+4
objective-c cocoa-touch ios8 nsset skspritenode
source share
1 answer

Thanks to Josh for solving this new problem on the road.

I have subclassed SKSpriteNode, overriding -isEqual and -hash, and both are what I prefer in implementing NSObject. Then I just searched / replaced everything in the project for "SKSpriteNode" for my subclass name, and everything returns to it in the iOS 7 build:

 -(BOOL)isEqual:(id)object{ return self == object; } - (NSUInteger)hash { return (NSUInteger)self; } 
+5
source share

All Articles