How do you get an iPhone's device name

Solution 1:

From the UIDevice class:

Swift version:

UIDevice.current.name

Objective-C version:

[[UIDevice currentDevice] name];

The UIDevice is a class that provides information about the iPhone or iPod Touch device.

Some of the information provided by UIDevice is static, such as device name or system version.

source: http://servin.com/iphone/uidevice/iPhone-UIDevice.html

Offical Documentation: Apple Developer Documentation > UIDevice Class Reference

Solution 2:

In addition to the above answer, this is the actual code:

[[UIDevice currentDevice] name];

Solution 3:

Remember: import UIKit

Swift:

UIDevice.currentDevice().name

Swift 3, 4, 5:

UIDevice.current.name