我有一个名为NumberX的整数和一个名为PlistX的plist.
例
int NumberX;
Run Code Online (Sandbox Code Playgroud)
PlistX:

我想知道我如何使NumberX =值为3
我想知道@property和@synthesise有什么意义.目前我使用以下内容来声明一些内容:
//Class.m
#import "Class.h"
CCNode *node;
@implementation
//init, etc..
Run Code Online (Sandbox Code Playgroud)
但我见过别人用过:
@property (nonatomic, etc..) CCNode* node;
@synthesise (nonatomic, etc..) node;
//I am not too sure on how this type of declaration works, please correct me on how it's done.
Run Code Online (Sandbox Code Playgroud)
它们似乎都以同样的方式工作,@ property和@synthesise方式的优点是什么?他们做不同的事情,如果是的话,那是什么?
我很想知道重新定位对象的真正重要性,以及什么时候应该完成.此外,当您更改场景时,它会自动释放所有内容,还是仍然在内存中?
谢谢
完整的代码在这里: http ://pastebin.com/rdjDGLJS
编辑:最新的代码片段取自原始海报评论
NSMutableString *spriteType;
- (void) pickSpriteType {
randomSpriteNumber = arc4random() % 2+1;
switch (randomSpriteNumber) {
case 1:
spriteType = [NSMutableString stringWithFormat:@"typeOne"];
break;
case 2:
spriteType = [NSMutableString stringWithFormat:@"typeTwo"];
break;
}
}
- (void) findSpriteNumber {
levelNumberString = [NSMutableString stringWithFormat:@"%d",levelNumber];
NSString *path = [[NSBundle mainBundle] pathForResource:@"plist_enemies" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
spriteNumber = [[[dict objectForKey:spriteType] objectForKey:levelNumberString] intValue];
}
- (void) initSprite {
[self moveUp];
for(int i = 0; i<spriteNumber; i++) {
if ([spriteType isEqualToString:@"typeOne"]) { …Run Code Online (Sandbox Code Playgroud) ios ×4
objective-c ×2
properties ×2
declaration ×1
if-statement ×1
iphone ×1
plist ×1
release ×1
string ×1