このメソッドを使用して nsmutablearray を初期化しています
- (void)getAllContacts
{
Contact *contact = [[Contact alloc] init];
self.allContacts = [[NSMutableArray alloc] init];
int i=0;
for (i=0; i<5; i++)
{
contact.nome = [[NSString alloc] initWithFormat:@"Bruno %d", i];
[self.allContacts insertObject:contact atIndex:i];
}
}
とても簡単です!しかし、その直後に、次のような要素を出力するために for を実行します。
for (int i=0; i<[self.allContacts count]; i++)
{
Contact *c = [self.allContacts objectAtIndex:i];
NSLog(@"i=%d\nNome:%@", i, c.nome);
}
そして、最後の要素「Bruno 4」の 5 回を表示します。0 から始まるのではなく、インクリメントします。0から始めるにはどうすればいいですか?