How to block people on an iPhone?

I have random numbers that keep calling me non stop, and an ex friend of mine keeps texting me saying very mean things about me and attacking me. I used to have an app on my old phone (it was an android) that would block numbers but I don't know how to do it on this phone. If anybody can help me out it would be greatly appreciated.

Contact your service provider to block those numbers. Obscene or harassing phone calls can be one of the most stressful and or if calls are obscene, you should call the police and file a report. Or change your phone number