简体   繁体   中英

Cocos2d: .plist file giving me a SIGABRT error

Hello I am making a side scrolling cocos2d app. I am using a .plist file for most of the data in my game. When I run the code it immediately gives me a SIGABRT error. I am new to objective c and cocos2d and I am not experienced with .plist files. This is the .plist file. 在此处输入图片说明

This is the code that I am pretty sure is causing the problem.

NSString *path = [[NSBundle mainBundle] bundlePath];
    NSString *finalPath = [path stringByAppendingPathComponent:@"GameData.plist"];
    NSDictionary *plistData = [NSDictionary dictionaryWithContentsOfFile:finalPath];

    NSMutableArray* characterArray = [NSMutableArray arrayWithArray:[plistData objectForKey:@"Characters"]];
    NSDictionary *theCharacterDict = [NSDictionary dictionaryWithDictionary:    [characterArray objectAtIndex:0]];


NSDictionary* characterDict = [NSDictionary dictionaryWithDictionary:[theCharacterDict   objectForKey:@"PlayerProperties"]];
    character = [Character createWithDictionary:characterDict];
    [self addChild:character z:kCharacterLevel];

I do not know if this is the code that is causing the problem. I will post more code if needed.

Okay I don't know if this is what is causing the error, but I immediately spotted an error in your code. NSMutableArray* characterArray The asterisk should be immediately before characterArray .

As I read further, there are several minor errors in the code you posted. Asterisks are in the wrong places are there are too many spaces in certain areas. My suggestion is to read through your code line by line to help catch such errors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM