iOS Development--Summary of device information (not yet finished ...) )

Source: Internet
Author: User

1. Get information about your device

Uidevice *device = [[Uidevice alloc] init];

NSString *name = device.name; Get the name of the device owner

NSString *model = device.name; Get the category of the device

NSString *type = Device.localizedmodel; Get localized version

NSString *systemname = device.systemname; Get the currently running system

NSString *systemversion = device.systemversion;//Gets the version of the current system

NSLog (@ "name:%@\nmodel:%@\ntype:%@\nsystemname:%@\nsystemversion:%@\n", Name,model,type,systemname, Systemversion);

2. Get unique identifiers for the device

NSString *identifier = [[[Uidevice Currentdevice] Identifierforvendor] uuidstring];

NSLog (@ "identifier:%@", identifier);

3. Create a UUID (a random identifier)

NSString *uuid = [self createuuid];

NSLog (@ "uuid:%@", uuid);

-(nsstring*) Createuuid {

NSString *id = [[Nsuserdefaults standarduserdefaults] objectforkey:@ "UUID"]; Gets the value identified as "UUID"

if (id = = nil)

{

if ([[[Uidevice Currentdevice] systemversion] Floatvalue] > 6.0)

{

APIs that can be used after iOS 6.0

NSString *identifiernumber = [[Nsuuid UUID] uuidstring];

[[Nsuserdefaults Standarduserdefaults] setobject:identifiernumber forkey:@ "UUID"];

[[Nsuserdefaults standarduserdefaults] synchronize];

}

else{

APIs used prior to ios6.0

Cfuuidref uuid = cfuuidcreate (NULL);

Cfstringref uuidstring = cfuuidcreatestring (NULL, UUID);

NSString *identifiernumber = [NSString stringwithformat:@ "%@", uuidstring];

[[Nsuserdefaults Standarduserdefaults] setobject:identifiernumber forkey:@ "UUID"];

[[Nsuserdefaults standarduserdefaults] synchronize];

Cfrelease (uuidstring);

Cfrelease (UUID);

}

return [[Nsuserdefaults standarduserdefaults] objectforkey:@ "UUID"];

}

return ID;

}

iOS Development--Summary of device information (not yet finished ...) )

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.