The hyperboloidal foliation method for nonlinear wave equations