Post

Replies

Boosts

Views

Activity

Reply to NavigationLink Issue on Device
Thanks for updating the code. Unfortunately, I do not have a device Xs/iOS 15.1 . Tested on iPhone 12 Pro Max/iOS 15.1 Exactly the same as the updated code: ZStack enabled as I have suggested: And the latter is what I intend and is not same as first image (left). As there is no guarantee that NavigationLink with EmptyView would be shown as actually empty or not, so, I usually make them under the hood using ZStack. (In my usual apps, the hood covers whole area without transparent areas.)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21
Reply to UIButton setBackgroundImage for different states not working
Which version of Xcode are you using? As far as I tried with buttons which I added on the storyboard with Xcode 13.1, I needed to change Style to Default to make setBackgroundImage(_:for:) effective. button1.setBackgroundImage(UIImage(named: "cardButtonSelected"), for: .normal) button1.setBackgroundImage(UIImage(named: "cardButtonUnSelected"), for: .selected) button1.isSelected = true button2.setBackgroundImage(UIImage(named: "cardButtonUnSelected"), for: .normal) button2.setBackgroundImage(UIImage(named: "cardButtonSelected"), for: .selected) button2.isSelected = true Apple introduced some big changes on UIButtons in iOS 15, many traditional codes related to UIButton would not work as before in the default settings on a new storyboard of Xcode 13.x.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to Axie
NO, at least not here. Contact to the author of the app.
Nov ’21
Reply to Can I add my app to the sharing popup menu?
Can I add my app to the sharing popup menu?  YES. You may need to add a Share Extension to your app. You can find some articles searching with "ios swift share extension". If you find some difficulty implementing your own Share Extension, many readers of this site can help if you can provide some more concrete details of your issue. (This old article of Apple may also be useful: App Extension Programming Guide.)
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to Freeze when deallocating large data structures
It seems to be impossible to deallocate such a data structure without the Swift runtime freezing. True. Deallocating an enum instance with indirect child instances would cause deallocating the children recursively. So, when deallocating long lasting list as in your code, it would make too deep recursive calls which may result any sort of unpredictable behaviors, crashing, freezing or anything you can imagine. You may need to deallocate all the nodes in the list without consuming the native call stack -- you need non-recursive algorithm. You cannot control the deallocations of structs and enums in Swift, so you may need to make it a class and implement deinit carefully. My first trial looks like this: class ListNode { var left: ListNode? var right: ListNode? init(_ left: ListNode?, _ right: ListNode?) { self.left = left self.right = right } deinit { if left != nil || right != nil { var nodesToRelease: [ListNode] = [self] ListNode.deallocateAll(&nodesToRelease) } } private static func deallocateAll(_ nodesToRelease: inout [ListNode]) { while let top = nodesToRelease.popLast() { if let leftNode = top.left { nodesToRelease.append(leftNode) top.left = nil } if let rightNode = top.right { nodesToRelease.append(rightNode) top.right = nil } } } } var node: ListNode? = nil for _ in 0..<150_000 { node = ListNode(nil, node) } print("Done creating list") node = nil print("Completed program (this is printed within a second)") This shows Completed program (this is printed within a second) within a second. Changing 150_000 to 150_000_000, you can observe increasing of the memory consumption first, and then decreasing after Done creating list. (Takes a few minutes to finish.) I haven't tried many cases, so there may be some flaws in my code and may not be efficient. But I think my code is well explaining the problem. If you know the recursion level of the data might get hundreds or more, you should better not use enum with indirect children.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to NSKeyedArchiver
Can you show a complete code to reproduce the issue? And please make your code properly formatted. As the editing feature is very limited in the def forums, you may need to use Your Answer to show additional info.
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
Reply to Center item in custom UICollectionView that scrolls both directions
In most of the APIs imported into Swift, bit position based flags such as UICollectionViewScrollPositionCenteredHorizontally is not Int. So, bitwise operator like | would not be applicable. UICollectionViewScrollPosition flags seems to be wrapped into a struct called UICollectionView.ScrollPosition which conforms to OptionSet protocol. When you use OptionSet constants, you need to write them in Set-like notations. Please try something like this:         theCollection.scrollToItem(at: thePath, at: [.centeredVertically,.centeredHorizontally] , animated: true)
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to Axie Infinity
This is not a place to request an invitation code of some specific app. Contact to the author of the app.
Nov ’21
Reply to Agreements
It is not clear enough, but you may need to visit the Agreements, Tax, and Banking page of App Store Connect. (Not the Account page of the developer site, which was shown in some notifications in case of me.)
Topic: App & System Services SubTopic: StoreKit Tags:
Nov ’21