Post

Replies

Boosts

Views

Activity

Reply to How to capture all byte data of a class instance
Question A: Is there an existing API call or data type that allows me to pass in a class object and returns all the byte data ? I don’t actually know, but consider a case where an object does reference other objects. Does “all the byte data” mean you want to capture the entire object graph? That’s not necessarily what you really want. Question B: If question A is no, could you recommend/suggest a way to achieve this? Sounds like you just need a serialization scheme to convert an object to a byte stream. Grabbing the underlying bytes via Data(bytes:count:) is one way of course, but you could also implement a custom scheme to explicitly serialize all the object properties you need. Then I’m guessing that however you generate a byte stream representing an object, the fun part is that you are using XOR to diff successive entries in your undo stack and storing these diffs efficiently, probably taking advantage of the diffs containing a lot of 0x00 bytes. Is that the idea? If so, then any serialization scheme that produces the desired behavior should work.
Topic: App & System Services SubTopic: General Tags:
Feb ’23
Reply to can't make this work.any ideas why it ain't working?
Note that your struct needs to conform to Decodable in order to use JSONDecoder, like this: struct Vinyl: Decodable { // assuming the same name as in your 2019 Stack Overflow post And you should definitely switch if possible to Decodable and JSONDecoder as shown by @Claude31. Consider JSONSerialization unofficially deprecated for Swift. Now as for this issue in the original code: But it can't get through the line of the if let localData statement. I don't know why. The “don’t know why” is due to using try? which silently eats any error thrown by the JSONSerialization.jsonObject() call. If you change it to regular try and enclose it in a do / catch block, then the error it catches will tell you exactly what the problem is.
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’23
Reply to Can I call setAlternateIconName without user consent?
It’s amusing that this guideline: This feature may not be used for dynamic, automatic, or serial changes, such as to reflect up-to-date weather information, calendar notifications, etc. ...basically tells you not to do something that the API doesn’t support anyway. It’s good to be thorough. But be mindful of this part: and the app includes settings to revert to the original icon. So just changing the icon in response to navigation actions within the app may not satisfy the guideline. Since we’re down to trying to parse the exact meaning of the review guidelines, I think you should just submit your app and see how it goes.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jan ’23
Reply to Can I call setAlternateIconName without user consent?
You should be able to call setAlternateIconName whenever you like. Is it not working in your case? Make sure to check for success via the completion handler, or by catching any error thrown if using the async version. If it succeeds, the system should present an alert to the user automatically. Is anything not working as expected? With that said, I’d be a little worried about this: Technically it is possible, but it seems to be a problem in the app review process. What does this mean? Did your app get rejected for this? If so, what was the reason? Are you trying to “get around” app review in some way?
Topic: UI Frameworks SubTopic: UIKit Tags:
Jan ’23
Reply to Can I call setAlternateIconName without user consent?
Is it possible to call a specific screen What does this mean? It doesn’t seem to correspond to the title of your post. without user consent That’s usually a red flag here in Apple-land. What exactly are you trying to accomplish? Note that setAlternateIconName always presents an alert after the change, so you can’t quietly change the icon without the user noticing. And while there doesn’t seem to be any specific discussion of this in the HIG or API documentation, the intent of this API is pretty clear: to let the user pick an app icon they like, such as a sports team logo or a more pleasing color scheme. It doesn’t support using the icon to display useful information like the built-in calendar and clock apps do.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jan ’23
Reply to Hashable, Equatable and Measurement
That condition always needs to hold, or else the type wouldn’t work correctly in hashed collections such as dictionaries and sets. Those work on the assumption that equal values being compared (such as a dictionary keys or set members) will first have equal hashes, and then have equal values. If you need (for example) 1 meter and 100 centimeters to be considered different for displaying as separate items in a list or something, then you can make a wrapper type that implements equality and hashing appropriately. But note this would require them to be considered not equal, and then it’s not obvious what the other comparison operations (greater-than and less-than) actually mean.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’23