swift5.2

Collection View layout bug when selectItem (Swift 5)

杀马特。学长 韩版系。学妹 提交于 2021-02-17 01:52:51
问题 After selecting cell from viewDidLoad Layout is change Before select cell After select cell let indexPath = IndexPath(row: SelectedFolderIndex, section: 0) collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredVertically) Layout func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: collectionView.frame.width/2.2, height: 55) } ViewDidLoad let

I am reloading my tableView after fetching data from API and after reloading tableView simply does not render any cell as I see in view debugger

我与影子孤独终老i 提交于 2021-02-05 12:03:41
问题 This is my API Fetch method where I am reloading my tableview.After reloading tableview does not render any cell. ``` API.shared.fetchAccomodations(completion: { (accResponse, error) in if let err = error { print("Failed to fetch accomodation Information ::" , err.localizedDescription) } if let response = accResponse { self.accomodationsData = response DispatchQueue.main.async { self.accomodationsData = response print(self.accomodationsData.count , self.accomodationsData) self.tableView

SwiftUI toggle() function on Published values stopped triggering didSet with Swift 5.2

筅森魡賤 提交于 2021-01-29 19:08:49
问题 I have just updated my Xcode to 11.4 from 11.3 and my project written in SwiftUI started to behave differently. I used to call toggle() function for boolean values and it used to trigger didSet property observer, however, it is not working any more. Let' say we have a State property called isSettingOn . I used to call this: isSettingOn.toggle() which was triggering didSet observer of the property. Now, only if I call this: isSettingOn = true it is working. My projects are all based on this

How to make a button draggable/movable with SwiftUI?

狂风中的少年 提交于 2020-12-12 15:52:12
问题 I am trying to make a Button Movable with SwiftUI. From what it looks like this should work. I have tried putting the Button with Text inside another ZStack and for a second it was working but as soon as I released the button, the dragging stopped and I couldn't drag anymore. I noticed that the tap was remaining in the center despite the button had moved. Also the dragging looked buggy. struct CircleButton: View { @State private var dragAmount = CGSize.zero var body: some View { ZStack {

Vapor 4 PostgreSQL CRUD without http requests

只愿长相守 提交于 2020-06-29 03:59:10
问题 I am writing backend using Swift 5 and Vapor 4, database is PostgreSQL 12. I have a question: how to interact with database (CRUD) locally, without POST or GET requests? All tutorials show how to CRUD only based on Request through HTTPS again. I already asked this question: Vapor 3 PostgreSQL CRUD without requests http BUT IT'S NOT A DUPLICATE QUESTION, Vapor 4 works completely different! Please, look at my current, working class for Vapor 3 (based on this answer: Is is possible to use Vapor

keyNotFound error when parsing OpenWeather JSON data (SwiftUI)

天涯浪子 提交于 2020-05-24 05:30:13
问题 I need to retrieve the "name" object by using openWeather API, and I manage to parse json and retrieve the data, but for its particular objects such as "name" I constantly receiving this error: keyNotFound(CodingKeys(stringValue: "name", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"name\", intValue: nil) (\"name\").", underlyingError: nil)) Need help to solve this issue. Thanks. This is my code(in 3 Files

Warning: Initialization of 'UnsafeBufferPointer<T>' results in a dangling buffer pointer

天涯浪子 提交于 2020-05-12 11:55:49
问题 After update to Swift 5.2 / Xcode 11.4 got a warning to following code: extension Data { init<T>(from value: T) { var value = value let pointer = UnsafeBufferPointer(start: &value, count: 1) self.init(buffer: pointer) } func to<T>(type: T.Type) -> T { return self.withUnsafeBytes { $0.load(as: T.self) } } } On line let pointer = UnsafeBufferPointer(start: &value, count: 1) I got Initialization of 'UnsafeBufferPointer' results in a dangling buffer pointer I can use @silenceWarning but it's