Lifelong NY'er: No, you do not have to whistle - that's only in the movies. Maybe at one time it was commonplace, but these days no. In fact, it might be considered demeaning to whistle.
Best way to grab a cab in NYC? It's not hailing - it's being stealthy and preemptive: Get yourself to a well traveled intersection and watch for a cab pulling over to drop off a fare - in Manhattan, most people seem to get off near the intersections - not worth it to fight traffic to get to your exact location - you walk another block or two. (Be very aware of the traffic - your life is at risk at this point). As soon as that party is out of the cab, hop in, shut the door quickly to take full possession of the turf (and as protection against possibly enraged bystanders who were hoping to grab that cab...) , give out with a brief 'Hi' or 'Thanks' and tell the driver clearly and concisely where you want to go. (Try your best to know that before getting into cab.)
The caveat to this method is this: It's best to do it with a NYC attitude - no hesistation, no polite overtures, just get in and state your business with alacarity and authority. If you're too polite or hesitate, the driver may get peeved at your audacity, but if you take control immediately, you're good. :)
There's nothing to be embarrassed about when taking this approach: Remember that drivers like taking good fares and making money, and time is money. You're helping the driver make money by moving quickly with this approach. Instead of wasting time and gas fighting through traffic and/or cruising around, to get to the next fare, they're back in business immediately.
If the driver doesn't want to take you where you want to go, they'll either tell you they can't go there (and perhaps offer an excuse), or tell you they're at the end of their shift and going off duty. So, you get out of the cab and try again. No harm, no foul.
That approach can also help you in another way: The driver will be more careful about taking the most efficient route to get to your destination, because you've shown them you know how get things done in NYC. There are always several ways to get somewhere, especially in a town like NY. A good, honest driver can get your there in half the time, for half the money, as opposed to a bad or dishonest one. Your attitude will likely help the driver to be a "good" one.