I solved all the issues by replacing the NSSortDescriptor class by the SortDescriptor structure.
Post not yet marked as solved
I have the same problem in Xcode 13.2. The only solution was to uninstall the 13.2 version and install the 13.1 version again. Very annoying.
I have the same issue with my Mac Mini M1. It stops scrolling on browsers and it starts jumping around on other applications. I filed a bug report. I hope they fix it for the final release because it makes the Magic Trackpad useless. Here is a quick video I made to show the problem. At first, it seems to work but then stops scrolling and fails two or three more times. It keeps failing every three or four attempts or every four or five seconds. I tried everything, but nothing solves the issue. It looks like a bug in Monterrey.
https://www.youtube.com/watch?v=OxhW7biM5m0
I got it. The option is in the Apple ID panel now.
Thanks
I got it. It is answered in the Swift Concurrency, Behind the scenes talk.
Thanks
In SwiftUI, views are created inside the definition of a structure and then initialized when an instance is created from that definition, therefore, you can't execute code anywhere you want, you can only do it from inside the structure's methods or closures. For instance, if you look at your code, you tried to call the print() function in the place were the properties of the structure and its methods are defined. This is not allowed. If you want to execute code when the instance of that structure is created, you have to define the structure's initializer:import SwiftUI
struct TestView : View {
let myvar = 150
init() {
print("myVar: \(myvar)")
}
var body: some View {
Text("Hello World!")
}
}The body property is a computed property which value is defined by a closure, so you can use print() inside that closure. The problem is that closures know what value to return when they only have one statement, but if there are more than one statement, you have to specify what should be returned with the return keyword. In the following example I print a message but I specify that I want the Text view to be the value returned by the closure.import SwiftUI
struct TestView : View {
let myvar = 150
var body: some View {
print("myVar: \(myvar)")
return Text("Hello World!")
}
}Views like HStack or VStack are defined with a Content closure. I'm still not sure how those closures work, but they are expected to return a list of other views, so you can't call the print() function from there. If you want to print a value after a view was created, you can use the onAppear() modifier: This modifier applies to any view.import SwiftUI
struct TestView : View {
let myvar = 150
var body: some View {
VStack {
Text("Hello World!")
.onAppear(perform: {
print("myVar: \(self.myvar)")
})
}
}
}I imagine there are other ways, but those are the ones I'm using right now.
Well, the answer, in case someone also finds this problem, was very simple (thanks Itai Ferber!). Since a while ago, we have the encodedData property available. This property returns the encoded data and calls the finishEncoding() method, so there is no need to provide an NSMutableData object or execute that method anymore. We just have to create the NSKeyArchiver object with the new initializer, encode the data, and then get it from the property.let coder = NSKeyedArchiver(requiringSecureCoding: true)/* encode things */let data = coder.encodedDataThanks again to Itai for his quick response.
Hi, Manuel. Thanks, but that's not what I'm looking for. I need a way to encode the record's metadata, not the record. The metadata not only includes the record's name and zone, but also the date and the token required to know which record is older. For that, Apple provides the encodeSystemFields(with: coder) method. The problem is that this method takes an NSCoder object that now I can't provide because the NSKeyedArchiver.init(forWritingWith: data) initializer was deprecated. You can read more here (go the the end of the page):https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitQuickStart/MaintainingaLocalCacheofCloudKitRecords/MaintainingaLocalCacheofCloudKitRecords.htmlThanks anyway.
Just in case someone's still looking for this, here is my solution. Replace the method in the AppDelegate class by the following: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
/
var storyboard: UIStoryboard!
let device = UIDevice.current.userInterfaceIdiom
if device == .pad {
storyboard = UIStoryboard(name: "iPad", bundle: nil)
} else {
storyboard = UIStoryboard(name: "Main", bundle: nil)
}
window?.rootViewController = storyboard.instantiateInitialViewController()
window?.makeKeyAndVisible()
return true
}This code loads the iPad.storyboard file on iPads or the Main.storyboard file in any other device.