One of the big benefits of using SwiftUI is that you can hot update the App like Flutter,UI code changed,Will be directly reflected in the simulator or the real machine,Greatly improve the efficiency of writing user interfaces,No need to change 1px,run,Various clicks,Then check the loop of effects。But it's too early to use SwiftUI,After all, there is still a lot of iOS 12 Equipment in operation[……]
Swift
Apple's new place of OC for a high-level programming language!
Recently, the drop grid input method has encountered several difficult to reproduce problems-the key is that it will not cause a crash。This makes the crash statistics function completely ineffective,The specific performance is that the input method will suddenly get stuck for a few seconds in some cases,Very annoying。Then I thought,macOS comes with activity manager,There is a "sampling" function,You can see the current execution (call) status of the corresponding process,Can I use it to analyze the cause of the error?
In Japan[……]
First of all, this is not a new technology,It's very old,So old that almost no one mentions it。
This is a product of Apple's MVC model,It was born when there was no iPhone,It is used in conjunction with the Xcode graphical setting interface-such as NIB,of course,Now it has become XIB,Oh,And storyboard。
Now if you want to bind one[……]
When developing iOS apps,Many applications need to set the color of the iOS system status bar according to the current App content color,Black or white-especially on iOS 13 After the system supports the black mode。
Normal,Others will tell you to do this:
|
1 |
UIApplication.shared.statusBarStyle = .default |
But this triggers a warning:[crayon[……]
It has been a very popular self-signed certificate for HTTPS decryption,Then there are a lot of people realize crack of App by modifying Apple's internal purchase receipt。In fact Verified Purchase should be connected to the server App,Server to communicate with Apple's servers,The results are then sent to the App - but a lot of developers (including individual developers and corporate developers) do not bother to go to a special server maintenance,Therefore, the direct use of App and Apple[……]
Many people will encounter in the development EXC_BAD_ACCESS ,I'm sorry,This time, Xcode does not give any detailed solutions。
usually,This is due to a memory error caused。In simple terms it is that you create an object A,But in the later time of the visit,A memory in this area have been moved to do the system he used,For example, put the object B here - your[……]
Processing time and date software development is a very common operation,Almost all programming languages provide a corresponding API to facilitate the development of the date and time to process,Swift is no exception,such as DateFormatter ,You can use it any Date
generally speaking,Swift inner String And it is NSString Bridged,For example, I have written String NSString and what difference?,In short we are here to discuss major,String[……]
Do the soft keyboard on a mobile device,So how to handle user clicks position,It is the first problem you encounter,in this problem,I have come a long way。
I touch a logical development since input method pocketed roughly classified into three stages,Now were Laijiangjiang design ideas,I hope this can help you。
The first generation of touch engine
Obviously,For a beginner,There's nothing better use of the control system,Full-featured[……]
In the development off the grid when the input method macOS,I encountered a problem of a more wonderful,This problem has plagued me now - the time when some places need to display a row of vertically centered text,How to make these characters real "center"?
At first glance this seems to make much sense,Well ...... like vertical center,On macOS [crayon-68fde4c3beae66[……]
When developed using Swift input pocketed,I met a very interesting question -Deduplication。
All to known,Candidate input method in the calculation will always be out there may be a duplicate options (such as code table and have a word in the lexicon,They may be different coding,But the word is the same and the like),This time you need to re,But while keeping the same order of candidates。
Others solutions
If you go online to find,Then[……]
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[……]
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[……]