【发布时间】:2011-07-19 10:13:41
【问题描述】:
我对使用 Cocoa 的 Objective-C 非常陌生,我需要帮助。
我有一个 for 语句,其中我将 i 从 1 循环到 18,并且我想在此循环中向 NSMutableArray 添加一个对象。现在我有:
chapterList = [[NSMutableArray alloc] initWithCapacity:18];
for (int i = 1; i<19; i++)
{
[chapterList addObject:@"Chapter"+ i];
}
我希望它添加对象,第 1 章、第 2 章、第 3 章...、第 18 章。我不知道如何做到这一点,或者即使有可能。有没有更好的办法?请帮忙
提前致谢,
【问题讨论】:
-
你的意思是你想要
Chapter 1、Chapter 2等字符串?
标签: objective-c cocoa string nsmutablearray int