Post

Replies

Boosts

Views

Activity

@ObservedObject Issue
I have a major issue with @ObservedObject.I have the following statement@ObservedObject var model: UserDatain a good number of views and before Beta 5, I did not have to pass this variable into the preview, nor did I have to pass his variable into other views which already have the above statement.But now I do have to and it's a mess. Is there anyway around this?
13
0
8.4k
Dec ’22
SwiftUI Gobbling Up CPU
I have beel fiddling with SwiftUI and it has taken up a huge amount of CPU %. Has anybody else experienced this? It it takes forever to build. I think I have it confused.My Xcode is shut down, but I still have two swift processes running at 98%.Something wrong here....
9
0
7.9k
Mar ’22
Apple CloudKit async function Doesn't Look Right
The function in question is the following. func records(for ids: [CKRecord.ID], desiredKeys: [CKRecord.FieldKey]? = nil) async throws -> [CKRecord.ID : Result<CKRecord, Error>] Note that the returned value looks like a dictionary of the form [CKRecord.ID : Result<CKRecord, Error>], but the input is an array of CKRecord.IDs. There are similar functions, but they return a tuple. Like the below example. func records(matching query: CKQuery, inZoneWith zoneID: CKRecordZone.ID? = nil, desiredKeys: [CKRecord.FieldKey]? = nil, resultsLimit: Int = CKQueryOperation.maximumResults) async throws -> (matchResults: [(CKRecord.ID, Result<CKRecord, Error>)], queryCursor: CKQueryOperation.Cursor?) Note that matchedResults is an array of tuples consisting of [(CKRecord.ID, Result<CKRecord, Error>)]. I would have thought that the return type in the first function would also be of the form [(CKRecord.ID, Result<CKRecord, Error>)]. What am I missing?
1
0
1.4k
Jan ’22
UIBarButtonItem With Image Breaks Constraints
I have a UIViewController wherein I set nav items, basically the title and the rightBarButtonItem. I use a SF Symbol for the image. The code is extremely simple. Here it is. func setupNavItem() {         self.navigationItem.title = "Problem in This View"                  let helpImage = UIImage(systemName: "questionmark.circle")         let rightBarItem = UIBarButtonItem(image: helpImage, style: .plain, target: self, action: #selector(showHideHelp))         navigationItem.rightBarButtonItem = rightBarItem     } When I navigate into this view, all heck breaks loose with the constraints. What gives? I'm using Xcode Version 14.0 beta 3 (14A5270f). See the constraint info below. 2022-07-18 16:58:59.998394-0400 NavBarItemExample[28793:996095] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want.  Try this:  (1) look at each constraint and try to figure out which you don't expect;  (2) find the code that added the unwanted constraint or constraints and fix it.      "<NSLayoutConstraint:0x600000a79810 UIImageView:0x136d28790.width <= _UIModernBarButton:0x136d274b0.width   (active)>",     "<NSLayoutConstraint:0x600000a7af80 '_UITemporaryLayoutWidth' _UIButtonBarButton:0x136d27280.width == 0   (active)>",     "<NSLayoutConstraint:0x600000a793b0 'IB_Leading_Leading' H:|-(>=11)-[_UIModernBarButton:0x136d274b0]   (active, names: '|':_UIButtonBarButton:0x136d27280 )>",     "<NSLayoutConstraint:0x600000a79400 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x136d274b0]-(8)-|   (active, names: '|':_UIButtonBarButton:0x136d27280 )>" ) Will attempt to recover by breaking constraint  <NSLayoutConstraint:0x600000a79810 UIImageView:0x136d28790.width <= _UIModernBarButton:0x136d274b0.width   (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
3
0
1.1k
Jul ’22
NavigationStack - No Back Button
I created a very simple project with a NavigationStack and a NavigationLink as follows. Code 1. NavigationLink("Go To Next View", value: "TheView")          .navigationDestination(for: String.self) { val in Text("Value = \(val)")          } This code works fine in the simple project. But when I put this simple code into my existing app's project using a NavigationStack, it navigates to the next view fine, but there is no back button. I am updating my Apple Watch target to use SwiftUI and I want to use NavigationStack. My app does use @ObservedObject and my important data is using @Publish in a singleton class which conforms to ObservableObject. But this NavigationLink code, Code 1, is extremely simple and should work fine, but it does not. The same problem happens with the following code. Code 2 NavigationLink { NextView() } label: {     MainRowView(rowText: "Saved") } When I switch to NavigationView, Code 1 is grayed out, but Code 2 works fine and has a back button. However, as you know, NavigationView is being deprecated, so I really need to fix this or have it fixed. I can't see how this could be a problem with my code as the code snippet is so simple and worked in the simple project.
4
0
2.6k
Aug ’22
iCloud Private Relay Messes Up Map Search on macOS
I'm using my Mac and have macOS 13.0. I searched for 'Vinyl Record Shops' and 'Search Nearby' with Private Relay Enabled and the Map moved to Denver, Colorado while I am in Orlando, Florida. When I disable Private Relay, the search did take me to Orlando, Florida, but when I disabled it just now, it took me to Dallas / Ft Worth. I have 'Maintain General Location' selected. I don't have this issue with iOS 16.1 on my iPhone. Anybody else have this problem?
1
0
619
Nov ’22
CKAssets Download Even When desiredKeys Excludes Them
I have an app with a CloudKit Public Database in which a CKRecord can contain a CKAsset or two that holds the url of image data. I don't want to always obtain the image data so my desiredKeys excludes the CKAsset key in the CKRecord in that case. I use the following Swift function. var (matchResults, queryCursor) = try await database.records(matching: query, desiredKeys: desiredKeys) The desiredKeys variable could be an array of strings with the keys of CKRecord fields I want to return or nil if I want all of the data including the asset data. After I have the records, I do the following. if let imageAsset = record["ImageAsset"] as? CKAsset, let url = imageAsset.fileURL, let data = try? Data(contentsOf: url) { self.imageData = data } However, when I exclude the "ImageAsset" key from the desiredKeys array, my if let imageAsset contains the asset information. Looking at the received data, I can see that other keys that I exclude are not being downloaded, but the CKAsset url appears to be downloaded. Why? I expected that the if let would have been nil and the code within the if let would not have been executed.
3
0
930
May ’23
SwiftData Predicate Issue Workaround
I actually have found a workaround to an issue I reported on earlier. Here it is by example. let predicate = #Predicate<Data> { data in data.result == result && data.variable?.starts(with: SomeString) ?? false } Note the data.variable?. and the ?? false. This works. I still don't think I should have to discover these things. Something needs to be fixed on Apple's end.
3
0
1.8k
Aug ’23
'UIStoryboard' and 'UIStoryboardSegue' was deprecated in visionOS 1.0 - Why?
I currently have a UIKit app which uses a UIStoryboard and which has a tab bar controller. I removed the tab bar controller from the storyboard and created a tab bar app in SwiftUI which has the UIKit views represented as UIViewControllerRepresentable within structs. I changed the visionOS app destination from 'visionOS Designed for iPad' to 'visionOS' because I want to see the tabs on the left side in visionOS. I got a ton of warnings and some errors. I fixed the errors (which were related to user location). But the warnings are with regards to the storyboard and storyboard segue. The app runs perfectly fine but the warnings warn that UIStoryboard and UIStoryboardSegue will not be supported in a future version of visionOS. I wonder first why this was done and second, how much time will I have to fix the warnings? Could I release the app as is and fix later or will the support be dropped in a short timeframe? One of the ways to create views for view controllers in UIKit is through a storyboard. If you kill those in visionOS, then you restrict a big way that one can embed a UIKit view controller in SwiftUI.
6
0
1.2k
Sep ’23