xcode 13 Enqueued from com.apple.root.background-qos
Since I updated to xcode 13, I am randomly getting the error "Enqueued from com.apple.root.background-qos".It works correctly with xcode 12. but i get crash with xcode 13 and it doesn't show the path of the error as you can see in the screenshot.I'm not using async-await. I am sending an Alamofire request sequentially.
It can happen when the page is refreshed, whether I am browsing the screen or not. I tried updating my Alamofire and other pods but the problem persisted.I did a lot of research but couldn't find a solution My xcode version is 13.2.1. 13 and 13.2 have the same problem.
do you know?
how many words do you know
See also questions close to this topic
-
SwiftUI, apply drawGesture only when over Image
I'm try to apply the gesture only when the user is over the Image display not when tapped outside the image.
Any suggestion how I can do? this following code draw also when user tap outside the image.
struct ContentView: View { @StateObject var am = AppManager() @State var switchToTakePicture = false @State var paths: [PathContainer] = [] @State var currentDraggingId = UUID() @State var spikoPic = #imageLiteral(resourceName: "spiko-16.jpeg") @State var centerOFimage = CGSize(width: 0, height: 0) var body: some View { GeometryReader { proxy in ZStack { Image(uiImage: spikoPic) .resizable() .scaledToFit() .position(x: proxy.size.width/2, y: proxy.size.height/2) .background(GeometryReader { Color.clear.preference(key: ViewRectKey.self, value: [$0.frame(in: .global)]) }) .gesture(drawGesture) // not correct ForEach(paths) { container in // draw and set the foreground color of the paths to red container.path .stroke(Color.red, lineWidth: 4) } } .onPreferenceChange(ViewRectKey.self) { rects in print(rects.first ?? .zero) } } } var drawGesture: some Gesture { DragGesture(minimumDistance: 0) .onChanged { value in // The point that the gesture started from let start = value.startLocation // The point that the gesture ended to let end = value.location // the properties of the rectangle to be drawn let rectangle: CGRect = .init(origin: end, size: .init(width: start.x - end.x, height: start.y - end.y)) // create a path for the rectangle let path: Path = .init { path in path.addRect(rectangle) } print("rettangolo = \(rectangle) orig \(rectangle.origin) - height \(rectangle.height) width = \(rectangle.width)") // remove the previous rectangle that was drawen in current // process of drawing paths.removeAll { $0.id == currentDraggingId } // append the new rectangle paths.append(.init(id: currentDraggingId, path: path)) } .onEnded { _ in // renew the dragging id so the app know that the next // drag gesture is drawing a completely new rectangle, // and is not continuing the drawing of the last rectangle currentDraggingId = .init() } } }
i want no box outside
-
How to navigate between NavigationLink while leave a part of main window stay the same in SwiftUI
I would like to navigate between different
NavigationLink
s inNavigationView
while some part of the main window stay the same. For example, I want to make a music app and I want to let the play controller always on top, while I can display different navigation contents (songs page, artists page...) using the rest of the window.Like what's showed in the picture below, I want to keep the red part always there while the blue part changes.
My code would be like below, but it won't work correctly. The
AlwaysStayView()
disappears when I click anyNavigationLink
on sidebar. So, how can I correct it or is there any solution (prefer in SwiftUI, but framework like UIKit would also be OK). I would appreciate it.NavigationView { List { NavigationLink { DiscoverView() } label: { Label("Discover", systemImage: "magnifyingglass") } NavigationLink { SongsView() } label: { Label("Songs", systemImage: "music.note") } NavigationLink { ArtistsView() } label: { Label("Artists", systemImage: "music.mic") } } } .listStyle(SidebarListStyle()) VStack { AlwaysStayView() SongsView() } }
-
NumberFormatter and unsigned with UInt64.max
I'm trying to create a string representing
UInt64.max
usingNumberFormatter
. Here's the code:let formatter = NumberFormatter() formatter.usesGroupingSeparator = true formatter.numberStyle = .decimal formatter.positiveFormat = "# ##0.#########" formatter.maximumSignificantDigits = 20 formatter.usesSignificantDigits = false formatter.maximumFractionDigits = 20 formatter.minimumFractionDigits = 0 formatter.alwaysShowsDecimalSeparator = false // formatter.roundingMode = .halfUp let text1 = formatter.string(for: NSNumber(value: Int64.max)) let text2 = formatter.string(for: NSNumber(value: UInt64.max)) print(text1) print(text2)
which prints:
Optional("9,223,372,036,854,780,000")
Optional("-1")but should print
Optional("9223372036854775807")
Optional("18,446,744,073,709,551,615")It looks like
NSNumber
is roundingInt64
and isn't taking theUIn64
. The obj-c version ofNSNumberFormatter
works fine.Am I missing something or is there a problem with
NumberFormatter
? -
Using UIBarButtonItemAppearance have both the system and the custom back button images
I am using
UIBarButtonItemAppearance
for the first time and I'm confused on how to put a custom image for the back button.This is how I do it:
private func createBarButtonAppearence(_ color: UIColor, textColor: UIColor) -> UINavigationBarAppearance { let appearance = UINavigationBarAppearance() appearance.titleTextAttributes = [.foregroundColor: textColor] appearance.largeTitleTextAttributes = [.foregroundColor: textColor] appearance.configureWithOpaqueBackground() appearance.backgroundColor = color let back = UIBarButtonItemAppearance() back.normal.backgroundImage = UIImage(named: "white_back_arrow") appearance.backButtonAppearance = back return appearance }
This successfully puts the
"white_back_arrow"
image as the back button but it also keeps the original iOS back button image as it shows:How can I avoid this behaviour?
-
how to detect app launch event from SharePlay
I am working on an app having SharePlay feature in it. I am looking for a mechanism to know when my app has been open through SharePlay invite on FaceTime call. Is it possible to get that event? Any help is much appreciated.
-
Set not Removing Duplicate Dates
I have a structure that displays entries sorted by date. The date is displayed once for all entries of the same date. The problem I have is that Set is not removing duplicate dates. If I have two entries with the same date, I have two blocks in the view with same entries in each block. See my original post here. If I enter multiple entries with the same date, uniqueDates (looking with the debugger) shows the same number of elements with the same date.
My theory is that Array(Set(wdvm.wdArray)) is sorting on the complete unformatted date which includes the time or other variables in each element. Therefore it thinks all the dates are unique. Is there anyway to use formatted dates for sorting?
struct WithdrawalView: View { @StateObject var wdvm = Withdrawal() var uniqueDates: [String] { Array(Set(wdvm.wdArray)) // This will remove duplicates, but WdModel needs to be Hashable .sorted { $0.wdDate < $1.wdDate } // Compare dates .compactMap { $0.wdDate.formatted(date: .abbreviated, time: .omitted) // Return an array of formatted the dates } } // filters entries for the given date func bankEntries(for date: String) -> [WdModel] { return wdvm.wdArray.filter { $0.wdDate.formatted(date: .abbreviated, time: .omitted) == date } } var body: some View { GeometryReader { g in VStack (alignment: .leading) { WDTitleView(g: g) List { if wdvm.wdArray.isEmpty { NoItemsView() } else { // outer ForEach with unique dates ForEach(uniqueDates, id: \.self) { dateItem in // change this to sort by date Section { // inner ForEach with items of this date ForEach(bankEntries(for: dateItem)) { item in wdRow(g: g, item: item) } } header: { Text("\(dateItem)") } }.onDelete(perform: deleteItem) } } .navigationBarTitle("Bank Withdrawals", displayMode: .inline)
Below is the class used by this module
struct WdModel: Codable, Identifiable, Hashable { var id = UUID() var wdDate: Date // bank withdrawal date var wdCode: String // bank withdrawal currency country 3-digit code var wdBank: String // bank withdrawal bank var wdAmtL: Double // bank withdrawal amount in local currency var wdAmtH: Double // bank withdrawal amount in home currency var wdCity: String var wdState: String var wdCountry: String } class Withdrawal: ObservableObject { @AppStorage(StorageKeys.wdTotal.rawValue) var withdrawalTotal: Double = 0.0 @Published var wdArray: [WdModel] init() { if let wdArray = UserDefaults.standard.data(forKey: StorageKeys.wdBank.rawValue) { if let decoded = try? JSONDecoder().decode([WdModel].self, from: wdArray) { self.wdArray = decoded return } } self.wdArray = [] // save new withdrawal data func addNewWithdrawal(wdDate: Date, wdCode: String, wdBank: String, wdAmtL: Double, wdAmtH: Double, wdCity: String, wdState: String, wdCountry: String) -> () { self.withdrawalTotal += wdAmtH let item = WdModel(wdDate: wdDate, wdCode: wdCode, wdBank: wdBank, wdAmtL: wdAmtL, wdAmtH: wdAmtH, wdCity: wdCity, wdState: wdState, wdCountry: wdCountry) wdArray.append(item) if let encoded = try? JSONEncoder().encode(wdArray) { // save withdrawal entries UserDefaults.standard.set(encoded, forKey: StorageKeys.wdBank.rawValue) } } }
I am trying to display all entries of the same date under the one date. This example shows what I want but not the 3 copies of the date and entries.
-
What is the correct way to change the background color of the status bar now in XCode 13?
What is the proper way to update the status bar background color in XCode13 using Storyboards. When you use the following code example it says to use statusBarManager of the scene.
override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. let statusBarView = UIView(frame: UIApplication.shared.statusBarFrame) let statusBarColor = UIColor(red: 0.40, green: 0.22, blue: 0.94, alpha: 1.00) statusBarView.backgroundColor = statusBarColor view.addSubview(statusBarView) }
- Getting Localized string not found in wkwebview
-
How to programmatically change the button foreground color in Xcode?
I have a button with a system image and no Title string. I want to programmatically change the foreground color of the system image. I tried
myBtn.setTitleColor(UIColor.systemYellow, for: .normal)
This doesn't work. I know I can change the foreground color using the Interactive Builder. In the button's Attribute Inspector, there's a Foreground field that allows me to change the foreground color, but I can't find the method that accesses that attribute.
Regards, Tim