Post

Replies

Boosts

Views

Activity

Reply to Swift, C, and memory leaks
Do I need to do something to ensure bytes is released, since it doesn't seem to be happening on its own? Definitely! See this note in the documentation for UnsafeMutablePointer.allocate(capacity:): When you allocate memory, always remember to deallocate once you’re finished. The Unsafe in the name is a reminder you’re in old-school C land now, where you need to free() at some point after every malloc().
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’24
Reply to A few questions about CodingKeys.
Try removing the decoder.keyDecodingStrategy = .convertFromSnakeCase line. You are already supplying an explicit key mapping via enum CodingKeys, so you don’t want the decoder to attempt to perform additional conversion on top of your mapping. Can't the enum be named something other than CodingKeys? CodingKeys is a special name recognized by the compiler to indicate that you have taken charge of defining the key mapping. So enum CodingKeyss will be ignored and the compiler will synthesize its own version of CodingKeys based on your property names. That, combined with the convertFromSnakeCase strategy, ends up performing the same name mapping that your explicit enum CodingKeys performs.
Topic: App & System Services SubTopic: General Tags:
Apr ’24
Reply to Is Apple Sign In Required if we use FB, Google, Amazon sign in?
Nothing says you have to use Sign in with Apple specifically, though it’s quite convenient that Sign in with Apple just so happens to already satisfy those requirements. But any third party would be free to develop a new sign in option that also satisfies those requirements. Maybe one or more such options already, or will eventually, exist. (Of course this is actually just a clever response to meddlesome governments forcing Apple to offer a more “open" platform. Now you aren’t forced to use Sign in with Apple but users still have an option for enhanced privacy.)
Apr ’24
Reply to How to get around asking for DOB
This is also spelling out in our end user agreement as well Unfortunately, sounds like maybe your license and app requirements got developed without considering App Store policies up front. If so, there’s no good solution aside from just making the changes needed to pass review. It also seems you ask for gender. Why do you need ? Indeed, be very careful there. I can’t even imagine what a “peer to peer sharing app” needs with gender. If it’s just for cosmetic purposes, such as choosing pronouns for addressing users in messages that you generate... well, be very, very careful. Or just don’t go there.
May ’24
Reply to How to disable screen capture or avoid screenshot taking programmatically in iOS
This gets asked a lot. (Search the forum.) Here’s one of the best answers I’ve seen so far: link. I think it’s usually more useful to rethink the requirement to prevent capture in the first place. Why is this particular data ok to view in the app but not ok to view later? Is it not the user’s data for them to handle as they wish?
May ’24
Reply to App rejection for use of alternate icons
Does choosing the alternate app icon in app settings not count as "within the app" ? By “general app settings” do you mean your app’s settings bundle that the user accesses via the system Settings app? Or just a page titled General that is inside your app itself? If in the settings bundle, then how do you actually change the icon? That wouldn’t give you any context from which to call UIApplication.setAlternateIconName() when the user makes a change. Or are you calling setAlternateIconName() at some point after the app launches/resumes after visiting your bundle in system Settings? I guess that could work, but probably doesn’t match their expectation that the icon-changed confirmation alert pops up immediately after the user performs a gesture to trigger the change.
May ’24
Reply to Detect iPhone unlock / lock
I need to immediately know when the iPhone is unlocked. Why? Can you detail what app functionality depends on this? There’s no specific notification for unlocking, but take a look at app delegate method applicationProtectedDataDidBecomeAvailable(_:) (link) and corresponding notification protectedDataDidBecomeAvailableNotification (link). I am a newbie in iOS/APP development. Welcome! You’ll find that Apple APIs tend not to just give you random information about the system (“is the device locked?”) but instead support more specific use cases like the delegate and notification given above: “can I access protected data right now?” It should work even if my app is not running. There are various events that can wake or launch your app (see LaunchOptionsKey at link) but unlocking isn’t one of them.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’24