Post

Replies

Boosts

Views

Activity

Color literals improve the performance?
I asked ChatGPT about color literals, and it responded me this. In Swift, you can declare a color literal by using the #colorLiteral expression. Here is an example of how you might use this expression: let color = #colorLiteral(red: 0.5, green: 0.5, blue: 0.5, alpha: 1.0) The #colorLiteral expression is useful because it allows you to refer to a color in your code without having to hard-code its RGB or HSB values. This can make your code more readable and maintainable. Additionally, using color literals can also improve the performance of your app because the color is compiled directly into your app's binary, which means that it is loaded into memory only once and can be accessed quickly. Is it really true that they are compiled directly into your app's binary? I've never heard of it.
2
0
1.2k
Dec ’22
_ session: URLSession, didReceive challenge: URLAuthenticationChallenge not being called
I'm trying to implement a Mutual TLS session on my app. I have already implemented a class that extends from URLSessionDelegate, URLSessionDataDelegate I already have my _ session: URLSession, didReceive challenge: URLAuthenticationChallenge implementation that "works" sometimes, and I say sometimes because is not always being called as it should. This is my code where I use the dataTask var urlRequest: URLRequest = setRequestHeaders(with: URLRequest(url: url))           urlRequest.method = .get           let sessionDelegate = MTLSURLSessionDelegate()           sessionDelegate.completionHandler = { [weak self] response in        // Here I handle my data after // didReceive response: URLResponse // didCompleteWithError error and didReceive data     }           let session = URLSession(configuration: .default, delegate: sessionDelegate, delegateQueue: OperationQueue.main) // I have tried with a nil queue           let dataTask = session.dataTask(with: urlRequest)           dataTask.resume() Like I said, this code is already working but sometimes I can see that the delegate is executing all its data delegate methods without calling _ session: URLSession, didReceive challenge: URLAuthenticationChallenge first Am I missing something here?
1
0
1.1k
Aug ’21