Goal: How can you ensure the button you're sewing is in the right place?

Which of the following methods is more reasonable for accomplishing this goal?
Attach the button with a safety pin to the cloth and then sew it on.