Detect Retina Display, iPad, iPhone 5 and iPhone less then 5

Detect which device you are using has become, by now, fundamental to better manage their own app.
The times where everything was ‘simple’ are over, now we have to optimize as much as possible for every device you use.
For this there are some API where it is possible to detect which device is currently in use and if it has Retina Display: