Bonjour,
cela fait plusieurs heures que j'essais de résoudre un problème sans succès.
Je souhaite donc obtenir l'avi de personne plus expérimenté.
Je développe une application iPhone, le principe est de réaliser une liste d'image miniature. Pour cela, j'utilise des thread pour chaque image, se qui me permet de les charger en asynchrone.
J'utilise une vue de type UIScrollView pour n'afficher que 9 images par page.
Au bout d'un certain nombre de page(toujours différent) mon application plante et m'affiche ceci dans le terminal:
1 2 3
| *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <CALayerArray: 0x12a330> was mutated while being enumerated.'
*** First throw call stack:
(0x3414c8bf 0x3439c1e5 0x3414c3e3 0x3750d34f 0x3750cec3 0x375f226b 0x376b45ef 0x34147813 0x3414072f 0x340a5f0d 0x3750cf21 0x376b45ef 0x34147813 0x3414072f 0x340a5f0d 0x3750cf21 0x374f4107 0x30927df3 0x34120553 0x341204f5 0x3411f343 0x340a24dd 0x340a23a5 0x30926fcd 0x37523743 0x291d 0x28dc) |
D'après mes tests il se pourrais que cela vienne de mon appelle à l'objet self, mais je ne sais pas quoi faire.
Mes thread sont appeler comme ceci dans une boucle for :
[NSThread detachNewThreadSelector:@selector(startTheBackgroundLoadImage:) toTarget:self withObject:dictionary];
et :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| - (void)startTheBackgroundLoadImage:(id) dictionary {
@synchronized(self) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CGRect frameThumbnail = CGRectMake([[dictionary objectForKey:@"x"] floatValue], [[dictionary objectForKey:@"y"] floatValue], WIDTH, HEIGHT);
NSUInteger index = [[dictionary objectForKey:@"index"] integerValue];
ThumbnailView * thumbnail = [ [ThumbnailView alloc] initWithStringURL:[[images objectAtIndex:index] objectForKey:@"thumbnails"] ];
thumbnail.frame = frameThumbnail;
thumbnail.index = index;
[self addSubview:thumbnail];
[thumbnail release];
[pool release];
}
}
} |
C'est difficile a expliquer, j'espère avoir réussit à me faire comprendre.
Quelqu'un aurait une idée ?
Partager