samsoffes/sstoolkit — Issue #92: Wrong ordering and duplicated items on scroll
Author: binho
Created: 2011-10-09 18:40:23+00:00
State: open

Hello,

I have an JSON response something like that:

```
{
description = "Look 01 desc";
id = 1;
images = (
"U6WfJrAbBAOKmXmGu6RUh6cyo6mU3hvC.jpg",
"LuDquFEnLs9e7ZbPKAtq443jr388pxN3.jpg",
"XNkPN40QLS16TOE12dacisPkrLdLwCuL.jpg",
"Cr7Dqrb7SlMQ88ZqDoKeZW97wUzITyYt.jpg",
"NrBAyczJ7swMv9Uk01is1RyiANq5THSx.jpg",
"qxnJsdgdUpW0ILfMQDTSRh4p8BsIIUCr.jpg",
"94m4doSkcVa9NBasxhIPjHyh9xonSGQ2.jpg",
"DwrRJcZHKZ9R5l3lWMhEQfGxQzEF5jte.jpg",
"w1dJumulkWhQOjpviiDdh8dMjluiLGpd.jpg",
"MnRdReQDflG0qDg4oLamk2Yu3UuVBmsy.jpg",
"jSk2WQWjAVTDOI6WmmqHFZZ9vu8MNilP.jpg",
"HYymei4a1LurYsRlL0QoAfNAkpzyyGLW.png",
"glJ252SoxwLErBhYyu7OukCpumfV9l2V.png",
"qhIeJXfQSuqZtBDjiMrWNNdiphjbhHmd.jpg",
"scsPQuog1HaAbFKPNzCIwoE8lJ0FeyQr.jpg",
"SPqywzPp7tG0tBiTcVI3opVvB4Mn1qrB.jpg",
"uBM80nGKkPETXPS6pILxj7SC8y5TopiE.jpg",
"Xq9h5L2qsUHZHjmWToWNzWwn0E9yupA4.jpg",
"qMofOKApH02vYShQ8QejS0xAAYFxmMw4.jpg",
"VyOSRyNP5NGhl5FEXTdynjZYsgBGbhfg.jpg"
);
name = "Look 01";
status = active;
"version_id" = 1;
videos = (
);
}
```

And when I do in itemForIndexPath:

```
- (SSCollectionViewItem *)collectionView:(SSCollectionView *)aCollectionView itemForIndexPath:(NSIndexPath *)indexPath
{
static NSString *const itemIdentifier = @"itemIdentifier";

SCImageCollectionViewItem *item = (SCImageCollectionViewItem *)[aCollectionView dequeueReusableItemWithIdentifier:itemIdentifier];
if (item == nil) {
item = [[[SCImageCollectionViewItem alloc] initWithReuseIdentifier:itemIdentifier] autorelease];
}

NSInteger i = (20 * indexPath.section) + indexPath.row;

@try
{
NSString *imagePath = [NSString stringWithFormat:@"%@/look/small_%@", imageURLResource, [[[itemList objectAtIndex:indexPath.section] valueForKey:@"images"] objectAtIndex: i]];
item.imageURL = [NSURL URLWithString: imagePath];
}
@catch (NSException * e)
{
NSLog(@"Error: %@", e);
}

return item;
}
```

"itemList" is my complete JSON response and "images" is all imagens inside this section of JSON.

First time loads ok, correct order etc but when I scroll to the bottom and to the top again the order is wrong and some duplicated items, could be a problem?

Rgds,
Cleber