EDIT: this is my full code:
i have a array how look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>destinataire</key>
<string>david</string>
<key>expediteur</key>
<string>sophie</string>
<key>idMessage</key>
<string>1729</string>
<key>message</key>
<string>ok a plus</string>
<key>photoExp</key>
<string>http://photos/hbrJUlrTgj.jpg</string>
<key>statusE</key>
<string>1</string>
</dict>
<dict>
<key>destinataire</key>
<string>david</string>
<key>expediteur</key>
<string>max</string>
<key>idMessage</key>
<string>1730</string>
<key>message</key>
<string>ok a plus</string>
<key>photoExp</key>
<string>http:///photos/4xlWoAHT8b.jpg</string>
<key>statusE</key>
<string>1</string>
</dict>
<dict>
<key>destinataire</key>
<string>david</string>
<key>expediteur</key>
<string>michel</string>
<key>idMessage</key>
<string>1731</string>
<key>message</key>
<string>ok a plus</string>
<key>photoExp</key>
<string>http:///photos/TR7oO6O8Z8.jpg</string>
<key>statusE</key>
<string>1</string>
</dict>
</array>
</plist>
i need to put new datas in this array but in my new data i have this :
<dict>
<key>destinataire</key>
<string>david</string>
<key>expediteur</key>
<string>sophie</string>
<key>idMessage</key>
<string>1729</string>
<key>message</key>
<string>ok a plus</string>
<key>photoExp</key>
<string>http://photos/hbrJUlrTgj.jpg</string>
<key>statusE</key>
<string>1</string>
</dict>
sophie is already exist in my array so i have to find the index in my array where sophie appears to put my new data
so i do this to try to find duplicates datas and replace it
if ([[allMessageArray valueForKey:@"expediteur"]containsObject:[dicoChat2 objectForKey:@"expediteur"]] )
{
for( int i=0;i<[allMessageArray count];i++)
{
NSDictionary *dicoChat22 = [allMessageArray objectAtIndex:i];
NSMutableDictionary * datas2= [[NSMutableDictionary alloc]init];
[datas2 setObject:[dicoChat22 objectForKey:@"destinataire"] forKey:@"destinataire"];
[datas2 setObject:[dicoChat22 objectForKey:@"expediteur"] forKey:@"expediteur"];
[datas2 setObject:[dicoChat22 objectForKey:@"photoExp"] forKey:@"photoExp"];
[datas2 setObject:[dicoChat22 objectForKey:@"statusE"] forKey:@"statusE"];
[datas2 setObject:[dicoChat22 objectForKey:@"idMessage"] forKey:@"idMessage"];
[allMessageArray replaceObjectAtIndex:i withObject:datas2];
[allMessageArray writeToFile:datAllString atomically:YES];
}
}
when i try to use replaceObjectAtindex:i it works but all my datas has been replaced in every index. so i know i didn't find the good index how i can found it?
thx