It is ok to have ice cream while losing weight, but it's not ok to have a pint.
The better solution would be to serve yourself a portion of ice cream...and then put half of it back. Better still, use a measuring cup and measure a real portion according to the nutritional information and eat it knowing exactly how many calories you are consuming.
And honestly, I wouldn't have had ice cream until my cravings were already at bay. It sounds like maybe yours are not. I can now treat myself ONCE IN A WHILE because my cravings are virtually gone. When I do indulge, I find doing so closer to bed time helps because I can sleep off any triggered cravings. I also find that chasing an indulgence with a glass of water squelches further cravings.