Crash sur: [NSKeyedArchiver archivedDataWithRootObject:self.data]

NiClouNiClou Membre
juillet 2014 modifié dans API UIKit #1

Bonjour à  tous,


Je rencontre un problème et j'avoue que je sèche un peu.


Dans un projet j'ai une classe de persistance qui reprend un peu le principe des user default.


Voici une méthode:



- (void) synchronize
{
@synchronized (self.data)
{
NSData *encryptedData = [[NSKeyedArchiver archivedDataWithRootObject:self.data] NL_AES256EncryptWithKey:userKey]; //La ça crash
BOOL success = [NSKeyedArchiver archiveRootObject:encryptedData toFile:[self filename]];

if (!success)
{
// we lost some data :(
NSLog(@Failed to synchronize to file %@", [self filename]);
}
}
}


Dans les logs de crash il m'indique que j'essaye de modifier le tableau pendant qu'il est "lu".

Hors j'ai protégé toutes les méthodes de ma classe par @synchronized (self.data).


 


Auriez vous une idée? Quelque chose que j'ai loupé?


 


EDIT: Voici plus d'infos:



*** Collection <__NSArrayM: 0x1756a800> was mutated while being enumerated.

0 CoreFoundation 0x2e95becb __exceptionPreprocess + 131
1 libobjc.A.dylib 0x390f2ce7 objc_exception_throw + 39
2 CoreFoundation 0x2e95b9b9 -[NSException name] + 1
3 Foundation 0x2f2dd647 -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] + 383
4 Foundation 0x2f2ddc2d -[NSArray(NSArray) encodeWithCoder:] + 189
5 Foundation 0x2f2dc479 _encodeObject + 1061
6 Foundation 0x2f2dd657 -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] + 399
7 Foundation 0x2f2dd329 -[NSDictionary(NSDictionary) encodeWithCoder:] + 921
8 Foundation 0x2f2dc479 _encodeObject + 1061
9 Foundation 0x2f2e2899 +[NSKeyedArchiver archivedDataWithRootObject:] + 157

Réponses

Connectez-vous ou Inscrivez-vous pour répondre.