天道酬勤,学无止境

swift4.2

TextField in SwiftUI loses focus when I enter a character

I have a problem when I enter a character within a TextField (Within ExerciseSetView), I have to re-click the text box to make it so I can enter another character. If I remove the bindings from the Textfield I can enter text fluidly. I think it has something to do with my presenter class and the updateSet function recreating a set instance because I have to replace some values two levels deep within an array. // // ContentView.swift // test // // import SwiftUI import Combine import CoreData class WorkoutExerciseSetVM: Hashable, ObservableObject { @Published public var id: Int @Published

2022-04-30 14:34:05    分类:问答    swift   swift4.2   swiftui

在ios swift中使用alamofire 5从multipartformdata上传带有参数的文件(Upload files with parameters from multipartformdata using alamofire 5 in ios swift)

问题 我正在尝试使用参数(multipartformdata)上传文件,但我无法使用新版本的 Alamofire 5 来完成,如果您对 Alamofire 5 有一些经验,请与我分享。 func uploadPluckImage(imgData : Data, imageColumnName : String, url:String,httpmethod:HTTPMethod,completionHandler: @escaping (NSDictionary?, String?) -> ()){ let token = UserDefaults.standard.string(forKey: PrefKeys.loginToken) ?? "" let authorization = ["Authorization" : "Bearer \(token)"] let parameters: Parameters? parameters = [ "garbageCollector": 0, "stuff_uuid": "2b4b750a-f4a6-4d61-84ce-7c42b5c030ee", "delete_file" : "" ] let headers : HTTPHeader? headers = ["Authorization" : "Bearer \(token)"]

2022-03-26 16:36:09    分类:技术分享    ios   swift   alamofire   multipartform-data   swift4.2

Xcode 10 not being able to archive project

I'm trying to upload a new version of an app that is already in the AppStore. Previous version was uploaded using Xcode 9.4. But now Xcode 10 will be required in order to get approval. Sadly, Xcode is not being able to archive the project, so I'm getting stuck on the first step, not even being able to generate the binary for submission. There is no error: According to Xcode, our archiving process has more than 2000 tasks, and is just gets stuck in arbitrary task (always the same). Xcode does not crash, does not show an error and does not complain. It just can't pass that task and the IDE stays

2022-03-26 06:23:06    分类:问答    ios   xcode   xcode10   swift4.2

Avoid Equatable and Hashable boilerplate, Swift 4.2

On project we are using classes for model's layer and because of that I have to write code like this: // MARK: - Hashable extension Player: Hashable { static func == (lhs: Player, rhs: Player) -> Bool { return lhs.hashValue == rhs.hashValue } func hash(into hasher: inout Hasher) { hasher.combine(self.name) } } Can this boilerplate can be somehow avoided? Is it possible to implement that Equatable compare by .hashValue by default? Thanks.

2022-03-22 02:19:17    分类:问答    swift   swift4.2   equatable

Upload files with parameters from multipartformdata using alamofire 5 in ios swift

I am trying upload files with parameters (multipartformdata) but i can't do it with new version Alamofire 5, if you have some experience with Alamofire 5 please share it with me. func uploadPluckImage(imgData : Data, imageColumnName : String, url:String,httpmethod:HTTPMethod,completionHandler: @escaping (NSDictionary?, String?) -> ()){ let token = UserDefaults.standard.string(forKey: PrefKeys.loginToken) ?? "" let authorization = ["Authorization" : "Bearer \(token)"] let parameters: Parameters? parameters = [ "garbageCollector": 0, "stuff_uuid": "2b4b750a-f4a6-4d61-84ce-7c42b5c030ee", "delete

2022-03-11 17:28:21    分类:问答    ios   swift   alamofire   multipartform-data   swift4.2

Could not load IOSurface for time string. Rendering locally instead swift 4

Could you help me with this problem when I running my project : Could not load IOSurface for time string. Rendering locally instead I don't know what is going on with my codding ..... pleas help .

2022-03-11 16:41:42    分类:问答    ios   swift3   swift4.2

Error with notification names while converting code to Swift 4.2

The code below was working fine before Swift 4.2: NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChange(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil) When I click the 'Fix' option, it becomes: NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChange(notification:)), name: NSNotification.Name.UIResponder.keyboardWillShowNotification, object: nil) But it is still marked an error. Here is the explanation: Type 'NSNotification.Name' has no member 'UIResponder' And then I tried to delete 'UIResponder'

2022-03-07 23:01:20    分类:问答    nsnotifications   xcode10   swift4.2