0
我是從一些字符串生成列表至多4cocos2d的組相同的字符串
NSUInteger total = MIN(4, myNSMutableArray.count);
CGFloat xPos = 0.0f;
CGFloat yPos = 450.0f;
CGFloat yPadding = 10.0f;
NSInteger count = 0;
for (ItemClass *item in myNSMutableArray) {
if (count == total) return;
CCLabelTTF *itemLabel = [CCLabelTTF labelWithString:item.name
dimensions: CGSizeMake(280, 50)
alignment:UITextAlignmentCenter
lineBreakMode:UILineBreakModeWordWrap
fontName:@"MyFont.otf"
fontSize:28.0f];
itemLabel.anchorPoint = ccp(0,0);
itemLabel.position = ccp(xPos, yPos);
itemLabel.tag = item.itemID;
[self addChild:itemLabel];
[myNSMutableArrayOfLabels addObject:itemLabel];
yPos -= itemLabel.contentSize.height + yPadding;
count++;
}
讓我們留我有像字符串列表:串1,串2,串3,串3,串3 ,串3.我想將它們分組,以獲得類似:
string 1
string 2
string 3 (4)
'myArray'的類型是什麼? NSArray,CCArray還是什麼? – 2012-03-21 15:51:21
@ RichardJ.RossIII:'NSMutableArray',謝謝! – 2012-03-21 15:53:30