Update (June 2016): In today's evolving device landscape, I have adapted to provide support for both touch and mouse input across all resolutions. With devices like iPad Pros having a touch interface equivalent to a 13" laptop and Windows laptops now commonly equipped with touch screens, it is important to cater to the varying user experiences.
While there are other similar SO responses that offer different methods for identifying user devices, none of them are foolproof. I suggest exploring those answers if determining the device type is crucial for your application.
It is worth noting that iPhones, among others, disregard the handheld
query, as detailed in this source. This behavior may extend to other smartphones due to similar considerations.
My current approach to detecting mobile devices involves assessing their width and utilizing corresponding media queries to identify them accurately. The provided link showcases some popular media queries, while additional ones can easily be found through a quick online search.
For more iPhone-specific detection techniques, particularly concerning Retina displays, I recommend referring back to the initial resource mentioned.