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?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
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....
I get the following.
403 Forbidden
Anybody else have this problem?
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?
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.
I'm getting this when I go to Accounts on Xcode and click on why Apple ID. I'm getting this on the current version and latest beta of Xcode. It's very disheartening. Anybody know what causes this?
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.
I have a project where I am upgrading my Apple Watch app to use SwiftUi and the SwiftUI lifecycle. For some reason, my destination views are missing the back button (<) and the navigation title. It all works fine with NavigationView, but I definitely want to go to NavigationStack and use the new API.
This is probably a simple question, but how can one have scrolling in one's Apple Watch app like that in the Workout App using SwiftUI? The scrolling which emphasizes each item as it scrolls by. I'm trying to recall, but can't.
I think that there is a mistake in the Wayfinder watch face for Apple Watch Ultra. Note that in my picture, longitude shows '-81.54327 W', but because W is used, longitude should be either 81.54327 W or just -81.54327.
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?
I have burned the midnight, no, 2 AM oil to knock out the ton of Sendable warnings on my app. I have worked the issues, but have two functions remaining where I am stuck. The functions are both CloudKit functions. One of them is shown in the image.
I am at a loss on how to clear this warning. Any amount of help would be most appreciated.
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.
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.
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.