What you have to do, Ron, is put in new 1-5/8" drywall screws on either side of where the nail popped. Then you can pull the nail out with needle nosed pliers. You want to put the screws into the ceiling joists so you will want to know which way the joists run. You want them to just go under the surface and not break the paper on the surface of the drywall. Put the screws an inch or so away from the popped nails on either side, if possible.
When you have tht done, you can spackle and sand flush. You might want to or have to dig out around the seam that is visible and retape the joint. Use drywall mud and fiberglass tape for this. Again, don't damage the paper on the front of the drywall and now under your paint any more than necessary. When this is all sanded flush, you cqn prime and repaint.