Remove AIS Interactive selected objects through loop

Hi
I would like to simulate the user scenario where user selected more than one AIS_Shape and wanted to remove them (not erase). i have tried the following and i am getting access violation error. could any one help me.

for (myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent())
{
myAISContext()->Remove(myAISContext()->Current(), Standard_True);
}

M.G.THIRUNAVUKKARASU's picture

Solved the problem by modifying the for loop like below
for (myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->InitCurrent())
{
myAISContext()->Remove(myAISContext()->Current(), Standard_True);
}