What you should not do:
Experts have for years pointed out that’s a bad idea – and now Apple is officially warning users not to do it.
“Don’t put your iPhone in a bag of rice. Doing so could allow small particles of rice to damage your iPhone,” the company says in a recent support note spotted by Macworld. Along with the risk of damage, testing has suggested uncooked rice is not particularly effective at drying the device.
What you should do:
If your phone isn’t functioning at all, turn it off right away and don’t press any buttons. The next steps depend on your specific circumstances, but broadly speaking: dry it with a towel and put it in an airtight container packed with silica packets if you have them. Don’t charge it until you’re sure it’s dry.
Wouldn't salt be better anyway?
Here, restaurants sometimes (honestly pretty rare) put rice in the salt dispensers to keep the salt dry, so I doubt salt is great at that.
Salt absorbs water, and then it does something called caking. Which means it glues into large clumps of crystal when wet then dried, instead of reverting to tiny cubes. The idea of the rice has nothing to do with moisture but to prevent the clumps after the salt dries with a physical barrier. If you shake it in place after it dries, the rice also mechanically break the lumps. It's an old restaurant trick because they use commercial table salt, which is specifically made for and restaurants has no anticaking agents (usually some form of silicate) and no iodine, so it's taste is not metallic. That's how all salt used to be. But modern household table salt does include it, and as result doesn't cake and it remains granular no matter the moist.