Water provides excellent shielding against ionizing radiation. While the radiation from the initial detonation is setting everything nearby on fire, the surface of the water will harmlessly evaporate. Since the boiling point of water isn't very high and the flash doesn't last very long, the whole body of water will stay cool, even if it's only a swimming pool.
I'm not as sure about the physics, but water should also give good protection against the shock waves generated by the explosion. Because water is much more dense than air, with high surface tension, acoustic waves tend to bounce off rather than go in (this is why you mainly hear only underwater things while swimming), and intense wind tends to generate foam on the surface rather than stir up turbulence underwater.
Falling debris will be falling slower, if at all, after it breaks the surface. The safety of diving in such conditions is doubtful, but I can't really quantize that.
All considered, if you are under nuclear attack, yes that is a good time for a swim. You might as well continue swimming until things stop falling and the air becomes relatively clear. Use a makeshift dust mask while going up for air. Since water stops neutrons so well, the radioactive isotope concentration would have to be pretty high for underwater fallout to be as dangerous as that in the air, but take care not to swallow too much.