У меня есть пользовательский класс с именем Profile
и NSMutableArray
, в который я добавляю объекты профиля на тот случай, если мне нужно будет идти вперед и назад в итерации.
Код такой:
@try {
currentProfile = (Profile *) [cache objectAtIndex:(int)currentPosition-1];
}
@catch (NSException * e) {
Profile *cached = [[Profile alloc] init];
[cached loadProfile:currentPosition orUsingUsername:nil appSource:source];
cached.position = NULL;
[cache addObject:cached];
currentProfile = cached;
[cached release];
}
//And the "log" i use to show the error
Profile *temp;
for (int i=0; i<[cache count]; i++) {
temp = (Profile *) [cache objectAtIndex:(int)currentPosition-1];
NSLog(@"%@ - %d e %d", temp.name, temp.position, temp.realId);
}
[temp release];
NSLog возвращает мне время кеширования с одним и тем же объектом. И.Е.
для len = 1:
первая - 1 е 1
для len = 2:
второй - 2 е 2
второй - 2 е 2
для len = 3:
третий - 3 е 3
третий - 3 е 3
третий - 3 е 3
и так далее ...
И что мне нужно это:
для len = 3:
первая - 1 е 1
второй - 2 е 2
третий - 3 е 3