A gunshot can be a good way to kill a pig, but I'd be wary of using a .22, depending on the size of the animal. Swine have thick skulls -- a .22 may do the job, but such a small caliber round might not make it through and instead ricochet off the skull. I personally know of at least one instance in which this happened.
The AVMA's euthanasia guidelines have a really handy diagram of where to shoot if using a gun to dispatch a pig. Check out page 59 of this document:
https://www.avma.org/KB/Policies/Docume ... anasia.pdf.