Objective c Cocos2d getChildByTag未返回精灵

Objective c Cocos2d getChildByTag未返回精灵,objective-c,cocos2d-iphone,cclabelttf,Objective C,Cocos2d Iphone,Cclabelttf,我正在尝试更改COCOS2DxCode(objective-c)中CCLabelTTF的文本。我是这样设置标签的: CCLabelTTF *progressLBL = [CCLabelTTF labelWithString:@"connecting..." fontName:@"Marker Felt" fontSize:10]; progressLBL.position = ccp( width + 4, (s.height) - hight - 15); CCMenu *menuHol

我正在尝试更改COCOS2DxCode(objective-c)中CCLabelTTF的文本。我是这样设置标签的:

CCLabelTTF *progressLBL = [CCLabelTTF labelWithString:@"connecting..." fontName:@"Marker Felt" fontSize:10];
progressLBL.position = ccp(  width  + 4, (s.height) - hight  - 15);
CCMenu *menuHolder = [CCMenu menuWithItems:publishingLinesButton , nil];
[self addChild:progressLBL z:10 tag:cnt];
CCLabelTTF *progressLBL = (CCLabelTTF *)[self getChildByTag:[dataInfo objectAtIndex:0]];
progressLBL.string = @"Updated";  
s是屏幕的高度和宽度,如果是一个整数,则cnt从1上升到13。然后,在创建标签大约5秒钟后,我得到如下结果:

CCLabelTTF *progressLBL = [CCLabelTTF labelWithString:@"connecting..." fontName:@"Marker Felt" fontSize:10];
progressLBL.position = ccp(  width  + 4, (s.height) - hight  - 15);
CCMenu *menuHolder = [CCMenu menuWithItems:publishingLinesButton , nil];
[self addChild:progressLBL z:10 tag:cnt];
CCLabelTTF *progressLBL = (CCLabelTTF *)[self getChildByTag:[dataInfo objectAtIndex:0]];
progressLBL.string = @"Updated";  
dataInfo是一个数组,索引0处的对象是一个整数。但是,当我运行此代码时,标签不会更改。我也尝试过:

CCLabelTTF *progressLBL = (CCLabelTTF *)[self getChildByTag:4];
但标签仍然没有改变


谢谢,如果这件事很简单,很抱歉浪费你的时间

事实是Objective-C数组包含对象,它不能包含基元类型。标记参数是一个整数,而您正在传递一个对象(可能收到编译器警告)。我假设该对象是一个NSNumber,因此您应该调用intValue访问器获取其值:

CCLabelTTF *progressLBL = (CCLabelTTF *)[self getChildByTag:[dataInfo objectAtIndex:0].intValue ];
使用较新的编译器语法,可以将其翻译为:

CCLabelTTF *progressLBL = (CCLabelTTF *)[self getChildByTag: dataInfo[0].intValue ];

事实上,Objective-C数组包含对象,但不能包含基元类型。标记参数是一个整数,而您正在传递一个对象(可能收到编译器警告)。我假设该对象是一个NSNumber,因此您应该调用intValue访问器获取其值:

CCLabelTTF *progressLBL = (CCLabelTTF *)[self getChildByTag:[dataInfo objectAtIndex:0].intValue ];
使用较新的编译器语法,可以将其翻译为:

CCLabelTTF *progressLBL = (CCLabelTTF *)[self getChildByTag: dataInfo[0].intValue ];

我会被诅咒的。只要找你的零钱就行了。不过我没有收到编译错误。我会被诅咒的。只要找你的零钱就行了。但是我没有得到编译错误。