Post

Replies

Boosts

Views

Activity

SWIFT: server certificate does NOT include an ID which matches the server name
I'm working on MBP OSX Ventura 13.5.2 I'm working with Swift 5 (Xcode 15.2) I have a local httpd configured with vhosts. I create my local certs using mkcert. When I visit the https://example site with Chrome the certificate is perfectly valid and there are no issues. When I try and contact the same site using a DataCallBack function to the URL I get the error "server certificate does NOT include an ID which matches the server name" In the log: Connection 1: default TLS Trust evaluation failed(-9807) Connection 1: TLS Trust encountered error 3:-9807 Connection 1: encountered error(3:-9807)
25
1
2.1k
Jul ’24
NSURLErrorDomain Code=-1003 ... again!
This happens when trying to connect to my development web server. The app works fine when connecting to my production server. The production server has a certificate purchased from a CA. My development web server has a locally generated certificate (from mkcert). I have dragged and dropped the rootCA.pem onto the Simulator, although it doesn't indicate it has been loaded the certificate does appear in the Settings app and is checked to be trusted. I have enabled "App Sandbox" and "Outgoing connections (Client)". I have tested the URL from my local browser which is working fine. What am I missing?
6
0
632
2w
addSubview with bounds not working
I'm using Swift to display some text in the middle of the screen, but I'm doing this programmatically instead of using the layout designer. So I'm starting with my version of a UILabel: class GenericLabel: UILabel I'm then creating one of these objects: let label = GenericLabel(frame: CGRect.zero) label.processResponse(componentDictionary ) view.addSubview(label) The processResponse function will set the text value, the font, fontsize, and set the bounds for where the text should be displayed on the screen. Currently I'm just wanting to position the text in the centre of the screen. During this process I send some messages to the console, like my calculation of the width and height and the bounds value. The console includes this: GenericLabel: default = centrex and centrey Utils:setSize: parent view bounds = (0.0, 0.0, 402.0, 874.0) Utils:setSize: obj size = (85.33333333333333, 20.333333333333332) Utils.setSize: centrey myframe.origin.y = 426.8333333333333 Utils.setSize: centrex myframe.origin.x = 158.33333333333334 Utils:setSize: myframe is now set to = (158.33333333333334, 426.8333333333333, 85.33333333333333, 20.333333333333332) self.frame set to (158.33333333333334, 426.8333333333333, 85.33333333333333, 20.333333333333332) Finally I set this frame to my GenericLabel self.frame = Utils.setSize(["centrex":0, "centrey":0], for: self) // You can see this message in the console above print("self.frame set to \(self.frame)") Unfortunately the text appears at (0,0) as in this screenshot. Why is the frame not working? Is there some setting overriding the frame?
2
0
94
1w
Main actor-isolated property can not be referenced
Hello I'm getting this error in my code and I don't know why. Can somebody explain this or point me at a help article. import UIKit var greeting = "Hello, playground" let imageView = UIImageView() imageView.image = UIImage(named: "image") Utils.getImageSize(view: imageView) class Utils { static func getImageSize(view imageView: UIImageView) { let image = imageView.image print("Image size = \(image?.size ?? CGSize.zero)") } } The error is as follows: Cheers Murray
4
0
106
4d
Positioning an image
This may seem really basic, but I'm not using the screen designer, I'm doing this old school (programmatically). I think I'm using Swift 5 (not actually sure). This image may help. So I created my own UIImageView class called GenericImage class GenericImage: UIImageView, @unchecked Sendable { ... } I create the GenericImage class and add it to the View Controller. Then I load the image and set some positioning within my GenericImage class let imageView = GenericImage(frame: CGRect.zero) self.view.addSubview(imageView) imageView.processResponse(componentDictionary ) In the GenericImage class I load the image and set some constraints. self.imageFromURL(urlString: imageUrl) self.translatesAutoresizingMaskIntoConstraints = false self.contentMode = .scaleAspectFit self.widthAnchor.constraint(equalToConstant: 100.0).isActive = true self.heightAnchor.constraint(equalToConstant: 100.0).isActive = true self.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true self.topAnchor.constraint(equalTo: self.centerYAnchor).isActive = true The image is displayed at the top left of the screen. I'm guessing that the code I have written should center the image on the screen. However, while I would like to know how to center the image, I also want to be able to position it at a specific place on the screen, using points (or pixels). Any suggestions?
3
0
94
1d