There are a critical lack of public restrooms in NYC, especially when walking around through the city all day. Residents have their homes and offices to use but tourists don't have those kind of options. The good news is that there usually are options, but you'll have to know where to look.
First of all, there are a number of bad places to look for bathrooms. The worst place to look are shops. Most stores in NYC are small and have very little space for merchandise, let alone public toilets. Even large shops don't usually come with bathrooms. Fast food establishments aren't a great place to find bathrooms either. Many places like Subway don't have bathrooms. Others like McDonald's, Burger King, or Chipotle have facilites at some locations. But I have seen McDonald's that require paying 25 cents to open the lock. I also saw a Chipotle that required scanning your receipt to open the lock. Restaurants, of course, have bathrooms for patrons. But I find that most restaurants do a good job keeping non-patrons out of the dining room. They are reluctant to let anyone in who isn't paying. Most corner stores, or bodegas as they're often known in NYC, are also too small to have public restrooms.
So what is a good place to look when nature calls? The most reliable option is hotel lobbies. Some small hotels won't have any options, but the larger ones all do. Hotels are much more public than most people realize. Even if it's not your hotel, just walk like you own the place. You can usually find the bathroom by looking on the basement floor. Besides, if you can't find the bathroom you can ask the bell service or doormen and they will usually point it out. This trick is especially useful downtown in places like the East Village, Lower East Side, and Soho where there aren't as many restroom options. Besides, in some hotels like the Plaza, the Muse, or the Standard the bathroom is almost an attraction unto itself.
Public parks all feature restrooms as well. The problem here is that if a park looks a bit rundown, the bathrooms are almost certain to be. Park bathrooms are regularly used by the city's homeless for dealing with their myriad hygiene challenges, so unless there is constant cleaning, a park bathroom might not work. These days, however, many city parks are supported by massive private donations and they have the budget for some sparkling bathrooms. Hudson River Park, Bryant Park, Central Park, High Line Park, and East River Park all have excellent facilities. The Bryant Park bathroom even has fresh flowers, attendants, and classical music playing. No wonder it has been voted America's third best bathroom! Other parks, more reliant on taxpayer funds tend to fall short, but they are an option in a pinch.
Another good option is bars and cafes. Bars at night are jammed with patrons and no one will notice you going in or out. During they day, they are quiet and the staff is almost never bothered with a tourist asking to use the toilets. Especially since they have a much harder cleanup job after a long night. Coffee shops are a little trickier, but I find they tend to be very accommodating. Starbucks has been famous in NYC for allowing the public to use their bathrooms, and this is still generally true. I have, however, started to see a few Starbucks with no public bathrooms. The other problem is that this is such a well-know fact that there can often be a 15 minute wait to get into the bathroom. Personally, when I have to go, I hate standing in line. I'd rather keep walking.
Major public buildings like Grand Central Terminal, Rockefeller Center, and the New York Public Library are all bathroom-friendly. In fact, almost any public library branch will have bathrooms. Chelsea Market has them too but nowhere near enough toilets and so the line can be brutal. And there are a few shops that are worth pointing out that have restrooms. Major department stores like Bloomingdale's, Century 21, and Macy's all have bathrooms. Apple stores all have bathrooms, J. Crew stores have bathrooms too! In short, there usually is a bathroom nearby but it might require some educated guessing about where to look.
There are even a few apps to download for your smartphone. Best Bathroom has a few good spots mapped. SitorSquat by Charmin has an impressive map-based list of bathrooms, both clean and not-so-clean. With all this info, you'll never have to risk that public urination ticket again!