Two years ago,I wrote an article entitled "ios VoiceOver support for visually impaired users"Articles,Inside describes how iOS end of the necessary support for VoiceOver,Then I developed a macOS input terminal pocketed,But unfortunately due macOS own system bug,Third-party input method can not obtain focus VoiceOver (mainly[……]
Programming Development
Ado,Directly on the code。
GET:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
// 创建一个会话,这个会话可以复用 let session = URLSession(configuration: .default) // 设置URL let url = "http://127.0.0.1/api/" var UrlRequest = URLRequest(url: URL(string: url)!) // 创建一个网络任务 let task = session.dataTask(with: UrlRequest) {(data, response, error) in do { // 返回的是一个json,将返回的json转成字典r let r = try JSONSerialization.jsonObject(with: data!, options: []) as! NSDictionary print(r) } catch { // 如果连接失败就... print("无法连接到服务器") return } } // 运行此任务 task.resume() |
POST:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
// 这个session可以使用刚才创建的。 let session = URLSession(configuration: .default) // 设置URL let url = "http://127.0.0.1/api/" var request = URLRequest(url: URL(string: url)!) request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") request.httpMethod = "POST" // 设置要post的内容,字典格式 let postData = ["email":"user@xxx.com","password":"123456"] let postString = postData.compactMap({ (key, value) -> String in return "\(key)=\(value)" }).joined(separator: "&") request.httpBody = postString.data(using: .utf8) // 后面不解释了,和GET的注释一样 let task = session.dataTask(with: request) {(data, response, error) in do { let r = try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSDictionary print(r) } catch { print("无法连接到服务器") return } } task.resume() |
[……]
Today, the group participants Someone made such a problem,Why use the characteristic dictionary type as a generic type constraint,It will inevitably error?
1 |
inheritance from non-protocol, non-class type 'Dictionary<String, Any>' |
Obviously,He said very clearly,"You can not be from a non-agreement、Non-type class inheritance. "。Obviously,The dictionary is a generic structure...
Then the solution is also very clear ideas,Create[……]
Problem
Pocketed in the development process input,I have always been plagued by a problem,That is when the user clicks on the left edge of the screen, UIButton of touchDown event almost turned into a [pencil-6[……]
Among developing pocketed input process macOS,I have been plagued by a strange question - text blurred。
Sub-pixel
No matter how I debug,Pocketed candidate text input method can not achieve the original text as clear and sharp。After a big ask God,The resulting experience is to see live a long time - upstreamSub-pixel rendering bug。
In many platforms have similar problems,macOS[……]
In iOS development,We often use Timer This class,For some repeat or delayed call。
but,In actual use,If you are used to periodically update the UI,Will be found Timer Call often[……]
Use custom sounds as notification sounds
In iOS 10 after,iOS uses a new UserNotifications As the notification API,This allows developers to use images、video、Sound and other rich media content as the notification,While further,You can also use the Notification Content Ex[……]
As early as last year,Off the grid user input methods have reported pocketed Chinese input method macOS can not type in normal mode MarkDown proper way cloud notes,After testing proved true,Embodied in the text when hit,buffer refresh will be strange delete a character before the cursor - on,no more, no less,To delete a。
Fiddle for a long time failed,Finally, I did not move all the contents out of print,Find[……]
For iOS developers,The face of app piracy,The biggest problem is not a technical break,Instead, more and more sharing of pirated Apple ID,Some people might say that piracy is equivalent to a "trial" of the,Like people will naturally go into positive ...... but in fact,Because of penny share account of piracy,Led to numerous independent developers and ultimately to the vote resume。
In short,last year,Surge author[……]