IOS 7.1 - 7.1.2 owners cannot open my game

I have a simple free iOS arcade game not working correctly, after installing from the App Store, for iPhone owners with iOS 7.1 - 7.1.2. The game is built with a Sprite Kit and Objective-C (no Swift, something never) but is very simple in nature and doesn't have any fancy code or complexity. It also works great for those with iOS 8.xx installed After downloading iOS 7.1 Simulator for Xcode 6, I was able to reproduce the problem: iPhone 4S, 5 or 5S running iOS 7.1 - 7.1.2 all crashes means , a launcher image appears, but when it needs to load a game from an SKScene class called MyScene it just doesn't open. The crash logs say the following:

+[SKLabelNode labelNodeWithText:]: unrecognized selector sent to class 0x1022503a0

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[SKLabelNode labelNodeWithText:]: unrecognized selector sent to class 0x1022503a0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001029a6495 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010270199e objc_exception_throw + 43
    2   CoreFoundation                      0x0000000102a3755d +[NSObject(NSObject) doesNotRecognizeSelector:] + 205

      

After the crash, Xcode takes me to some Apple code page about "dispatch_once" and highlights line 68:

dispatch_once(predicate, block);          Thread 1: signal SIGABRT

      

Basically, inside MyScene, there is an (id) initWithSize method: (CGSize). Inside I created

static dispatch_once_t onceMS;
dispatch_once(&onceMS, ^{

      

Inside dispatch_once I have 4 things: 1. An instance of audioController is created (the class responsible for playing back looped background music). 2. SKSpriteNode spriteNodeWithImageNamed: 3. SKLabelNode labelNodeWithText: 4. SKLabelNode labelNodeWithText:

All 4 of these things should be displayed once, at the start of the game: they are visual instructions on how to play. The background music explains itself. I tried commenting on the whole thing, but it still showed the same crash logs as before. I kept commenting out the whole static dispatch_once and still crash the game. Can someone please publish some wisdom? I don't know what to do due to my lack of experience.

+3


source to share


1 answer


As per the documentation +[SKLabelNode labelNodeWithText:]

just not available on iOS7

I literally have no experience with SpriteKit, but you should be able to replace all instances

SKLabelNode *node = [SKLabelNode labelNodeWithText:@"your text"];

      

from:

SKLabelNode *node = [SKLabelNode labelNodeWithFontNamed:@"HelveticaNeue-UltraLight"];
node.fontSize = 32;
node.text = @"your text";

      



You can also create your own category in SKLabelNode:

@interface SKLabelNode (iOS7Compatibility)
+ (instancetype)mba_labelNodeWithText:(NSString *)text;
@end

@implementation SKLabelNode (iOS7Compatibility)
+ (instancetype)mba_labelNodeWithText:(NSString *)text {
    SKLabelNode *node = [self labelNodeWithFontNamed:@"HelveticaNeue-UltraLight"];
    node.fontSize = 32;
    node.text = text;
    return node;
}
@end

      

which allows you to use:

SKLabelNode *node1 = [SKLabelNode mba_labelNodeWithText:@"your text"];

      

You should not name the category method labelNodeWithText:

because you don't want to overwrite methods in categories.

+6


source







All Articles