Skip to content

[BUG] Using UIDevice.current on isPhone and isPad variables. #165

Description

@Zandor300

If you see the following lines:

https://github.com/dennisweissmann/DeviceKit/blob/master/Source/Device.generated.swift#L584
https://github.com/dennisweissmann/DeviceKit/blob/master/Source/Device.generated.swift#L591

/// Returns whether the device is an iPhone (real or simulator)
public var isPhone: Bool {
  return (isOneOf(Device.allPhones)
          || isOneOf(Device.allSimulatorPhones)
          || UIDevice.current.userInterfaceIdiom == .phone) && !isPod
}

/// Returns whether the device is an iPad (real or simulator)
public var isPad: Bool {
  return isOneOf(Device.allPads)
          || isOneOf(Device.allSimulatorPads)
          || UIDevice.current.userInterfaceIdiom == .pad
}

UIDevice.current is used.

Imagine this example; I'm running on an iPhone X. I'm getting an instance of .iPad6 and checking for .isPhone on that instance. From my understanding, it would return true since (UIDevice.current.userInterfaceIdiom == .phone) == true.

Do note that I haven't tested this.

@dennisweissmann mentioning you since you like that so much 😉 and because I can't assign you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions