Open koolahmedkhan opened 9 years ago
Typical you save data with the XMPP Stream JID of the current user, so you need to include that in your predicate.
I cleaned up the roster data using following code.
-(void) logout {
[self deleteAllEntities:@"XMPPGroupCoreDataStorageObject"
inContext:managedObjectContext_roster];
[self deleteAllEntities:@"XMPPResourceCoreDataStorageObject"
inContext managedObjectContext_roster];
[self deleteAllEntities:@"XMPPUserCoreDataStorageObject"
inContext: managedObjectContext_roster];
}
-(void)deleteAllEntities:(NSString *)nameEntity inContext:(NSManagedObjectContext*)theContext {
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:nameEntity];
[fetchRequest setIncludesPropertyValues:NO]; //only fetch the managedObjectID
NSError *error;
NSArray *fetchedObjects = [theContext executeFetchRequest:fetchRequest error:&error];
for (NSManagedObject *object in fetchedObjects)
{
[theContext deleteObject:object];
}
error = nil;
[theContext save:&error];
}
Hi Geeks ,
I am having an issue cleaning up the database after user logout. When new user login from the same device the messages of old user been displayed.
Please help me out :(