Posts

Post marked as solved
11 Replies
3.5k Views
Hi,I'm trying to keep a constant kerning on a UILabel's text when I set it as justified.I've tried setting it explicitly as an attribute, and it works just fine for all the alignment modes but justified.let attributes = [NSAttributedString.Key.kern: 1.0] let attributedString = NSAttributedString(string: label.text!, attributes: attributes) label.attributedText = attributedStringAny clue to how should I tackle this?As a test, I'm working on a blank iPhone Xr screen. UILabel centered horizontally and vertically. Set its width to 280, lines to 0 and text to: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."I'd like it to keep a constant kerning while varying the space between words in order to satisfy the alignment mode of justified.
Posted
by Nasonov.
Last updated
.
Post not yet marked as solved
0 Replies
955 Views
Hi,I'm facing this issue:App A is online and has been on the app store for a couple of years. Now, I've built another app, from a different mac, called B, and I'd like it to become the update of app A.What would be my options here?1) Recover the original Xcode project from the old mac and go from there (no git/github available).2) What if I don't have the original project on hand? What If I want to start afresh with a new project in a new mac (like I did with app B) and go from there? Is there a way of merging the two, later in the process? What should I need to take care of? I understand that the bundle ids need to be the same, but what for the certificates?
Posted
by Nasonov.
Last updated
.
Post marked as solved
4 Replies
8.1k Views
Hi,I'm looping over a list of strings and for each one of them I'm going to make an Alamofire request to an API endpoint.func readStrings() { [...] for name in array { getResults(artistName: artist) } } func getResults(name: String) { let headers: HTTPHeaders = [ //request headers ] let requestEndpoint = "ENDPOINT\(name)" AF.request(requestEndpoint, headers: headers).validate(statusCode: 200..<300).responseJSON { [weak self] response in //Parse the JSON //If the status code is outside that range, throw an error and break the loop. }Problem is that when I get an error code, i.e. 409, I'd like my closure to throw, in order for my readStrings() function to break the loop and then display a message to the user.I don't quite understand well why I can't throw inside that closure. I get this:Invalid conversion from throwing function of type '(_) throws -> ()' to non-throwing function type '(AFDataResponse<Any>) -> Void' (aka '(DataResponse<Any, AFError>) -> ()')
Posted
by Nasonov.
Last updated
.
Post marked as solved
3 Replies
749 Views
HiI have an array of Strings and for each one of them I need to make an Alamofire request to extract a specific value from the outputted JSON.let array = ["A", "B","C"] for variableName in array { AF.request("API ENDPOINT \(variableName)").responseJSON { response in //Parse the JSON //Write a value to a .txt file on disk together with the variableName: i.e (variableName;JSONValue) } }No problem with that.Thing is, when I go to write the extracted values to a .txt file in the completion handler, the order of the Array is not observed. I understand that the request is async so it all depends on how much time every single request takes, hence the unordered list. So, how could I keep the .txt file list sorted following the order of the Array?Edit:Yes, I could create another array with all the results inside. Then sort it (using some kind of sorting algorithm to reflect the order of the initial array), and then write it to the .txt file. But I was wondering if I somehow can skip this part. Expected result:let array = ["A", "B","C"] Textfile = A;(some value from the JSON request);B;(...);C;(...)But I get this instead:Textfile = B;(some value from the JSON request);C;(...);A;(...)
Posted
by Nasonov.
Last updated
.
Post marked as solved
4 Replies
3.2k Views
Hi,I'm retrieving a json by using this piece of code:AF.request("https://postman-echo.com/get?foo1=bar1&foo2=bar2").responseJSON { response in print(response) }Problem is that I get this:{ args = { foo1 = bar1; foo2 = bar2; };Instead of this:{ "args":{ "foo1":"bar1", "foo2":"bar2" },Why? Shouldn't it return a properly formatted json like in the second example?
Posted
by Nasonov.
Last updated
.
Post not yet marked as solved
5 Replies
718 Views
I can't wrap my head around getting autolayout to work in a prototype cell inside a table view. I've placed a button in the center of my cell. Then I've centered it horizontally and vertically in the container but when I switch to a different iPhone the button moves and it won't stay centered. Why does it behave like that? What am I missing? I've tried all kinds of constraints.
Posted
by Nasonov.
Last updated
.