-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Device.swift usable from objc #224
Make Device.swift usable from objc #224
Conversation
PiwikTracker/Device.swift
Outdated
|
||
// The native screen size | ||
public let nativeScreenSize: CGSize? | ||
@objc public let nativeScreenSize: CGSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You changed the nativeScreenSize to non-optional, but for macOS it is not defined. Correct me if I am wrong on that point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My issue was that optional non class parameter like CGSize?
cannot be represented in objc. I got a build error when prefixing it with @objc
.
As a Swift rookie, I decided to remove the optionality. Could you advice what is the best thing to do in that situation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see your issue there. Yeah. Only pointers to objects can be represented as optionals in Objective-C (null pointer then).
Since making this a pointer would be very weird I think there would be two solutions. Either define "no native screen size is defined" as CGSize.zero
or as "is equivalent to screen size". I think the first would be better, since a screen size with no width or height could easily be understood as "not defined". Either way, please add a short comment in the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely. Thanks!
PiwikTracker/Device.swift
Outdated
case "iPhone10,3": return "iPhone X (GSM+CDMA)" | ||
case "iPhone10,4": return "iPhone 8 (Global)" | ||
case "iPhone10,5": return "iPhone 8 Plus (Global)" | ||
case "iPhone10,6": return "iPhone X (Global)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Thanks!
…s not defined on the running platform
If you merge develop in here I am fine to merge. |
…e_accessible_from_objc
@brototyp: done |
@manuroe Lovely, thanks! I will add a Changelog entry. |
* Device.swift: make it a class usable from objc * Device.swift: Add human readable platform names for iPhone 8, 8 Plus and X * Device.swift: Make nativeScreenSize return CGSize.zero if the value is not defined on the running platform
* Device.swift: make it a class usable from objc * Device.swift: Add human readable platform names for iPhone 8, 8 Plus and X * Device.swift: Make nativeScreenSize return CGSize.zero if the value is not defined on the running platform
Hi,
This PR turns Device.swift into a class that can be usable from objc.
It also gives human readable names to latest iPhones.