Skip to content

Getting values like device name uses UIDevice.current #167

Description

@Zandor300

I personally find it weird behaviour that it will return the current device name when executing the following code:

Device.iPhoneXs.name

Would return Zandor's iPhone even though I'm kind of referencing a different device.

I think putting a fatalError(...) or returning nil would be a more logical behaviour. fatalError(...) would notify the developer of incorrect behaviour immediately.


Another solution could be to check if we are referencing the current device:

Device().name

and if not, do something like described here: https://www.hackingwithswift.com/example-code/language/how-to-add-warnings-and-errors-to-your-code-using-warning-and-error

#error("Can't get the name of a different device from the current one.")

This would produce an error at compilation when my first example is being used.


Could be a possible change for 2.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions