user3385029
user3385029

Reputation: 1

How to detect and display device info on iOS

I'm a starter in obj-c programming and I need to know how to display device info ( name, device type, ios version )

I you know the answer, please tell me and keep in mind i'm a starter with xcode ;)

Upvotes: 0

Views: 420

Answers (4)

Naga Mallesh Maddali
Naga Mallesh Maddali

Reputation: 1005

Please refer to UIDevice Class. It has all accessible system information properties. This is a singleton class. You can access this class instance like this : [UIDevice currentDevice]

For example if you want to access device model, you can access like this :

[UIDevice currentDevice]. model

Please refer this link to get information about all properties : https://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html

Upvotes: 0

Nazim
Nazim

Reputation: 64

    NSLog(@"uniqueIdentifier: %@", [[UIDevice currentDevice] uniqueIdentifier]);
    NSLog(@"name: %@", [[UIDevice currentDevice] name]);
    NSLog(@"systemName: %@", [[UIDevice currentDevice] systemName]);
    NSLog(@"systemVersion: %@", [[UIDevice currentDevice] systemVersion]);
    NSLog(@"model: %@", [[UIDevice currentDevice] model]);
    NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel])

;

Upvotes: 0

klcjr89
klcjr89

Reputation: 5902

You may try something like this: I use this for in-app support emailing from users.

#import <sys/utsname.h>

- (void)yourMethod
{
    struct utsname systemInfo;
    uname(&systemInfo);
    NSString *appVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
    NSString *osVersion = [[UIDevice currentDevice] systemVersion];
    NSString *machine = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
}

Upvotes: 0

Eduardo Urso
Eduardo Urso

Reputation: 296

I've used these information in an App that I developed so I did the following code. I think this may help you. I just didn't understand what you mean with device type.

To get the device model:

// get model from UIDevice
NSString *modelDevice = [UIDevice currentDevice].model;

To get the iOS Version:

//get the iOS version
NSString *systemVersion = [[UIDevice currentDevice] systemVersion];

To get the device name:

/** Method responsible to get the device name
 *
 * @return device Name
 */
+ (NSString *)deviceName
{
    size_t size;

    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    char *machine = malloc(size);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
    NSString *platform = [NSString stringWithUTF8String:machine];
    free(machine);

    return platform;
}

Upvotes: 3

Related Questions