iPad fullNameFromDevice is not retrieved while iPhone fullNameFromDevice is properly retrieved

StackOverflow https://stackoverflow.com/questions/16856452

  •  30-05-2022
  •  | 
  •  

Sample code to get fullNameFromDevice

I have implemented this sample category to get the "fullNameFromDevice" inside my application.Even this example is also not giving me fullNameFromDevice for iPad.There is not any issue to read iPhone device or iPad/iPhone simulator's name using this category.Only issue comes with iPad name.What problem can be? Suggest me the appropriate solution of this issue.

有帮助吗?

解决方案

Your iPad's name doesn't fit naming patterns suggested by this category.

Look at -(NSString *)fullNameFromDevice:

if (![self deviceNameContainDeviceKind])
    return nil;

Then at

-(BOOL)deviceNameContainDeviceKind
{
    return [self.name rangeOfString:@"iPhone"].location != NSNotFound
    || [self.name rangeOfString:@"iPod"].location != NSNotFound
    || [self.name rangeOfString:@"iPad"].location != NSNotFound;
}

You can see that if device's name does not contain "iPhone", "iPod" or "iPad", fullNameFromDevice will return nil.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top