Hi guys,
i am trying to remove objects from my NSMutableArray but i keep getting bad_access error.
I used "removeAllObjects" and "removeObjectAtIndex" but none of these work.
If i add objects to this array , everything is fine.
What i want to do is to clear my array before filling it again.
I didnt release the array before trying to fill.
Thx for the help.
Bye
code:
[tab_Demandes removeAllObjects];
for (NSDictionary *demandeD in demandes)
{
NSInteger i=0;
NSString *title = [demandeD objectForKey:@"Title"];
NSString *desriptif = [demandeD objectForKey:@"Description"];
NSString *Id = [demandeD objectForKey:@"Id"];
NSString *created = [demandeD objectForKey:@"Created"];
NSString *statut = [demandeD objectForKey:@"Statut"];
NSString *copropriete = [demandeD objectForKey:@"Copropriete"];
NSString *immeuble = [demandeD objectForKey:@"Immeuble"];
NSString *lot = [demandeD objectForKey:@"Lot"];
NSString *auteur = [demandeD objectForKey:@"Author"];
NSString *auteurId = [demandeD objectForKey:@"IdAuthor"];
NSString *auteurLogin = [demandeD objectForKey:@"Login"];
Demande *dem =[[Demande alloc] init];
dem.demTitle=title;
dem.demId=Id;
dem.demCreated=created;
NSString *descriptifDecode = [desriptif stringByReplacingPercentEscapesUsingEncoding:
NSASCIIStringEncoding];
dem.demDescriptif=descriptifDecode;
dem.demIdCopro=copropriete;
dem.demIdImmeuble=immeuble;
dem.demIdLot=lot;
dem.demStatut=statut;
dem.demAuteur=auteur;
dem.demIdAuteur=auteurId;
dem.demLoginAuteur=auteurLogin;
//[tab_Demandes replaceObjectAtIndex:i withObject:dem];
//i=i+1;
[tab_Demandes addObject:dem];
//[dem release];
}
When do i need to release the objects i add to the tab if i need to remove them later? because of memory leaks.