Post

Replies

Boosts

Views

Activity

Converting macOS system colors to iOS system colors in NSAttributedString
When syncing an NSAttributedString between devices, it seems that macOS system colors are decoded as "UIExtendedGrayColorSpace" black color on iOS. For example, if I have text on the Mac and chose systemColorRed, this is converted to UIExtendedGrayColorSpace black on iOS. I would like to convert the macOS system red (for example) to the iOS system red, but I'm not sure the best way to do this. My question is: has anyone discovered an efficient and clean way to convert macOS system colors to iOS system colors when syncing between devices? I have seen that the system colors on both devices have a consistent hex value when reading the color components. A possible solution would be to save the hex value of the colors in the attributed string. We could then enumerate the hex values and exchange the attributed string foreground color for the appropriate system color of whatever device is being used. I would greatly appreciate thoughts regarding this. Thank you everyone!
2
0
718
Aug ’23
LiveActivity error thrown is not ActivityAuthorizationError?
I have implemented Live Activity in my app but have encountered occasional errors when a user attempts to start a Live Activity. According to Apple's documentation, the error thrown should be an ActivityAuthorizationError but this has not been my experience in testing. I have been able to cast it as an NSError or an Error, but not as an ActivityAuthorizationError or a LocalizedError. The code I've been using to start the Live Activity is pretty straightforward I think: do { let _ = try Activity.request(attributes: activityAttributes, contentState: initialContentState) as Activity<MyActivityAttributes> } catch { print(error.localizedDescription) // I would like to present an alert that provides a failure reason and recovery suggestion. } In my testing I can see the following error message: Error Domain=com.apple.ActivityKit.ActivityInput Code=1 "(null)" UserInfo={NSUnderlyingError=0x600003b17d20 {Error Domain=com.apple.ActivityKit.ActivityAuthorization Code=4 "(null)"}} The error shown in the UserInfo seems to be an ActivityAuthorization error, but I can only cast it as an NSError or Error. I would really like to provide the specific failure reason and recovery suggestion to users who experience a failure. Has anyone else come across this? Are there suggestions on how to actually get access to the ActivityAuthorizationError type? Thank you all.
0
1
626
Jul ’23