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