|
lord funk posted:Yeah good luck. I just went through this a few weeks ago, and was surprised at how difficult heterogenous arrays were to encode / decode. Heterogeneous collections are always going to be a pain under strict static typing. It essentially demands extraction of protocols and wrapper enums.
|
# ? Sep 9, 2020 19:42 |
|
|
# ? Apr 19, 2024 22:39 |
|
We use this for json in a few places https://github.com/SwiftyJSON/SwiftyJSON Be aware that it recurses through the whole json object though, so if you have really big json arrays and/or a ton of nesting it can get slow. There was one spot where we had a 10000+ array of some json structures and we had to fall back to passing it as [Any] or [[String: Any]] depending on if we needed to access anything in it.
|
# ? Sep 10, 2020 03:04 |
|
These are kinda cool https://github.com/marksands/BetterCodable
|
# ? Sep 10, 2020 03:25 |
|
frogbs posted:I realize i'm just getting started with Swift, so everything is going to have a learning curve, but i'll be damned if I can't wrap my head around using Codable to parse even moderately complicated/nested JSON. Codables one of those things that kind of looks gnarly on paper, but in practice turns out to be pretty elegant. Theres a few sites which can just sort of magic up class definitions and stuff to work with defined JS feeds, and studying the output of those can be pretty enlightening. Its really just a way to stuff class heirachies into actual heirachies and vice versa. Also like most "schemaless" type things, hetrogenous arrays usually mean to me "Rethink this". Get your datastructures right BEFORE starting your code, if at all possible.
|
# ? Sep 18, 2020 11:21 |
|
duck monster posted:Also like most "schemaless" type things, hetrogenous arrays usually mean to me "Rethink this". Get your datastructures right BEFORE starting your code, if at all possible. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
# ? Sep 18, 2020 11:55 |
|
Heterogenous collections can still have schema—unless it’s impossible to declare an enum which describes the contents of the collection?
|
# ? Sep 18, 2020 18:43 |
|
duck monster posted:Codables one of those things that kind of looks gnarly on paper, but in practice turns out to be pretty elegant. Theres a few sites which can just sort of magic up class definitions and stuff to work with defined JS feeds, and studying the output of those can be pretty enlightening. Its really just a way to stuff class heirachies into actual heirachies and vice versa. Yeah, I tried using this https://app.quicktype.io/ with the feed i've been working with (https://api.weather.gov/gridpoints/PQR/110,101/forecast), but run into some syntax errors with the code Quicktype spits out. I'm ging to upgrade to Xcode 12 and see if I have better luck. I also stumbled across this library for dealing with weather.gov data in Swift today, so i'm going to give that a shot too: https://github.com/WeatherProvider/NationalWeatherService-Swift For the curious, here's what Quicktype spits out from that weather.gov feed. Does this look like it's handling nested things like 'Period' correctly?: code:
|
# ? Sep 18, 2020 22:27 |
|
gently caress xcode 12 why do I even bother updating this poo poo
|
# ? Sep 24, 2020 22:15 |
|
Works great over here. My previous non-use of tabs has apparently avoided some pain.
|
# ? Sep 25, 2020 01:21 |
|
Uh oh I'm a tabber and haven't updated yet. What's the beef ?
|
# ? Sep 25, 2020 03:36 |
|
TheReverend posted:Uh oh I'm a tabber and haven't updated yet. What's the beef ? Tabs in your tabs: https://www.jessesquires.com/blog/2020/07/24/how-to-fix-the-incomprehensible-tabs-in-xcode-12/
|
# ? Sep 25, 2020 04:03 |
|
That's just recursion. 🤷♂️ Hey since we're speaking tabs, is there a way to. It get whatever tab I'm on to be the breakpoint viewer. Sounds dumb but I'd like it to open.....in a new tab.
|
# ? Sep 25, 2020 04:19 |
|
TheReverend posted:That's just recursion. 🤷♂️ Same blog has a post that might help! https://www.jessesquires.com/blog/2018/07/01/xcode-tip-debugging-behavior-new-tab/
|
# ? Sep 25, 2020 04:21 |
|
What we did was add editor tabs like people have been asking for since forever because some people prefer them to the window tabs we added about a decade ago. We still have window tabs too though since folks have workflows built around them. For example I have behaviors set up to create window tabs for search, debugging, build results, and test results.
|
# ? Sep 25, 2020 09:43 |
|
anyone have a good way to do a bottom half modal?
|
# ? Oct 16, 2020 16:10 |
|
I'm trying to do this official SwiftUI tutorial which I found linked from the Xcode 12 website but this tutorial is for Xcode 11 and mentions things like "Single View App" which I don't see in Xcode 12. I'm sure it doesn't matter too much but do they have an up to date Xcode 12 SwiftUI tutorial or is there a better one elsewhere? Just seems kinda silly that Apple has a "what's new in Xcode 12" website but haven't updated their tutorials to actually use Xcode 12.
|
# ? Nov 4, 2020 21:33 |
|
We retired a bunch of templates in Xcode 12, consolidating on App and Document App templates to simplify things for developers. What you get with the App template is essentially what you got from the Single-View App template in Xcode 11. To most closely match Xcode 11, select the App template and (if presented with the choice) choose “UIKit/AppKit App Delegate” for the Life Cycle option.
|
# ? Nov 4, 2020 22:41 |
|
eschaton posted:We retired a bunch of templates in Xcode 12, consolidating on App and Document App templates to simplify things for developers. What you get with the App template is essentially what you got from the Single-View App template in Xcode 11. Oh, alright, thanks. Other than some minor things like the live preview button being different it hasn't matter much. e: Ok so I'm on a 13" MBP and I'm trying to look at both Safari and Xcode at the same time and it's virtually impossible. In Xcode I've hidden everything but the editor but I can't size it down (horizontally) past some arbitrary limit. On the Safari side I can make the window smaller horizontally but at some point it stops letting me resize it and the two windows overlap. Also the full screen split screen doesn't seem to work with Xcode and Safari? Boris Galerkin fucked around with this message at 00:52 on Nov 5, 2020 |
# ? Nov 5, 2020 00:44 |
|
KidDynamite posted:anyone have a good way to do a bottom half modal? use a UIPresentationController
|
# ? Nov 11, 2020 03:47 |
|
What do Swift developers think of this? https://www.iosapptemplates.com/blog/swiftui/swiftui-drawbacks Accord to this Swift UI isn't yet ready for complex projects. Florian does a lot of good stuff on Swift so I'm inclined to agree.
|
# ? Nov 11, 2020 03:51 |
|
Nothing I currently work on has a minimum SDK that admits SwiftUI. If I was starting something new for fun then I would absolutely try it. Starting something for work, I wouldn't go whole hog, but I'd wedge it in to a couple screens at least.
|
# ? Nov 11, 2020 05:03 |
|
We redid ours in swiftUI, it wasn't too difficult by itself. My main annoyance with it is that they did a second iteration to make it complete in ios14, but didnt backport any of that poo poo so we cant use it.
|
# ? Nov 11, 2020 22:27 |
|
I won't be getting a silicon Mac any time soon, but does this mean that Metal apps will run natively in the Simulator?
|
# ? Nov 17, 2020 22:06 |
|
lord funk posted:I won't be getting a silicon Mac any time soon, but does this mean that Metal apps will run natively in the Simulator? I think it depends on whether it's implemented for simulators. Like when I was doing stuff with NETunnelProvider a while back I could only test it on a real device, because the simulator doesn't implement the lower level stuff for vpns.
|
# ? Nov 18, 2020 00:45 |
|
I thought Metal was already supported with some limitations in the simulator? https://developer.apple.com/documentation/metal/developing_metal_apps_that_run_in_simulator Edit: I understand better what you are asking. I imagine it depends on if Metal on the M1 GPU implements more Metal features than the A14 versions do. I could see an “M1X” or “M1Z” variant in the large MBP, iMac, or Mac Pro implementing more features than are available on the A14 just like the AMD GPUs don’t have the same features as Metal on the A14. So probably not. Pulcinella fucked around with this message at 01:08 on Nov 18, 2020 |
# ? Nov 18, 2020 00:57 |
|
We haven't bumped the GPU family if that's what you're wondering. Otherwise it works the same way it does for iOS 13 and later: the Metal jobs are serialized and shipped out to the host GPU to execute.
|
# ? Nov 18, 2020 03:55 |
|
pokeyman posted:Nothing I currently work on has a minimum SDK that admits SwiftUI. If I was starting something new for fun then I would absolutely try it. Starting something for work, I wouldn't go whole hog, but I'd wedge it in to a couple screens at least. I wanted to see how much work it would be to get it into one of our apps and I found that Widgets were a good place to learn some basics.
|
# ? Nov 18, 2020 05:49 |
|
dc3k posted:I wanted to see how much work it would be to get it into one of our apps and I found that Widgets were a good place to learn some basics. That's a good idea. Now to ponder what a useful widget might look like…
|
# ? Nov 18, 2020 06:59 |
|
PM inbox count for Awful
|
# ? Nov 19, 2020 07:42 |
|
That could work. Also makes me realize that Mail offers no widgets.
|
# ? Nov 19, 2020 07:53 |
|
I work on an app with a tableview whose data comes from a realm db. That tableview’s cells display status information about the model objects - the status info is calculated on the model object, and the cells use a lazy var to access that status info and layout the cell. This is all done on the main thread, so scrolling performance is bad. I’ve been tasked with moving the calculation of that status info to a background thread. I’m struggling to figure out how to replace a lazily calculated bool property on the cell that tells model object to do the calculation with something that does that calculation off the main thread without a nested nightmare of functions with completion handlers. Anyone have any top level insight as to how to do this?
|
# ? Nov 20, 2020 00:26 |
|
I'm a web developer that's pitching in on an iOS client for our main application. So far I've been working on just adding functions for fetching data from our endpoints which has been pretty easy so far, but I want to learn how to write UI stuff as well. I want to start by adding a relatively simple component to an existing view that we have where a user searches to find their Twitter handle and selects it. After they select an account I want to replace the search field with this: I have a few questions about how I would do this. My guess is that I want to use a UIStackView for the outer container, with a UIImage for the Twitter logo, a UILabel for the Twitter handle, and a UIButton for the X button (possibly with a UIImage inside it because that little X is an SVG.) Does this sound right? I'd like to build this programmatically because I've watched some videos of Interface Builder and some videos of people doing AutoLayout programmatically and the latter seems a lot more appealing to me. I also understand that if multiple people are committing to .xib files at once it can cause a real nightmare for merge conflicts. Admittedly I googled stuff like "do I need interface builder" so I think I probably got answers from people who also don't like interface builder. I'm also not sure where I should put the actual code for this. This is not really a reusable component, it only appears here, but it feels like maybe I should still create a separate file called like SelectedTwitterView that subclasses UIStackView and exposes some way of handling setting the username and dealing with the close button being tapped. Is that normal or would it be best to just put it all inside the view controller for the screen that it's on? Finally, if I have two views that sort of replace one another (the search field, and this one) is it better to add and remove them as state changes, or just hide and unhide them? Thanks!
|
# ? Nov 21, 2020 18:35 |
|
I’m pretty sure what you’re looking for can be done with a uitextfield - you can get the cancel X for free, and I think it has a left side accessory view you can use for the Twitter icon
|
# ? Nov 21, 2020 18:51 |
|
Oh neat, it's not actually a text field though (i.e. you can't type in it and clicking the cancel button shouldn't necessarily clear it) does that matter? It does look a lot like a text field.
|
# ? Nov 21, 2020 19:03 |
|
If there's no editing the text then yeah your proposed layout makes sense to me. You might want to double-check the compression resistance and content hugging priorities so e.g. the twitter logo doesn't get squished when someone has a long twitter handle. UIButton knows how to display an image, so for the X button you can just call setImage(_:for:) and give at least the normal state (ideally also a highlighted state). And I would absolutely put this in its own class. Could subclass UIStackView, or just subclass UIView and add a stack view as a subview. Up to you if you wanna put it in its own file; if it's only used in one place I like to define it where it's used, so it's easy to find. Usually I would hide/show (or, visually equivalent but animatable, set alpha to 0 or 1) rather than continuously add/remove subviews. There are times it's better to remove and re-add, but default is hide/show.
|
# ? Nov 21, 2020 19:17 |
|
prom candy posted:Oh neat, it's not actually a text field though (i.e. you can't type in it and clicking the cancel button shouldn't necessarily clear it) does that matter? It does look a lot like a text field. ...now I'm confused. it was a search field before the user typed/tapped search and now it looks like one but isn't necessarily interactive? looking at the image I am expecting to be able to tap onto the name to search again, or tap the cancel X to clear this search and restore the unsearched view. if that's not the case I think it should look different.
|
# ? Nov 21, 2020 19:18 |
|
Oh, yeah, if you're switching between a text field and a mostly-static field then I would just use UITextField. It'll ask its delegate whether it should allow editing and what should happen when tapping the X (I think), so you can prevent editing at certain times if you want.
|
# ? Nov 21, 2020 19:20 |
|
dc3k posted:I wanted to see how much work it would be to get it into one of our apps and I found that Widgets were a good place to learn some basics. I wish I had been smart and done this. I built a new e commerce checkout for work with SwiftUI and it was great for the first 90%. Trying to finish out the last 10% which requires integrating with some 3rd party frameworks might kill me. Also the keyboard is trash and it’s very bad for users.
|
# ? Nov 21, 2020 19:23 |
|
ketchup vs catsup posted:...now I'm confused. it was a search field before the user typed/tapped search and now it looks like one but isn't necessarily interactive? The problem is we need to not only save the user's twitter handle but also the special little twitter user id, so rather than being able to just type your handle in we need you to use this autocomplete search and select one of the results, which we then pass to the server when you hit a "save" button below. If you come back later on we'd need you to first remove your account by clicking the X, then search and select another one (or save it with nothing selected if you just want to clear your account.) It's not the greatest UX but it's also buried pretty deep in a settings area that doesn't get used too often (which is why I wanted to start here.) That said it probably would be nice if the design made this look a little less like a text field. Right now when the search is active the left icon is a magnifying glass rather than the twitter logo, but otherwise it really does look like our text field component. That's a good note and I'll bring that back to our designer on Monday. And I think I'll probably build it out as a UIStackView in case it ends up coming back looking nothing like a text field. This is just one of those cases where we get a design, then we get into building it and go "hey we can't actually do that the way you designed it" and then the designer fires back a compromise. The nice thing is I'm pretty familiar with the annoying edges because I already built this whole thing in React for our web app. pokeyman posted:And I would absolutely put this in its own class. Could subclass UIStackView, or just subclass UIView and add a stack view as a subview. Up to you if you wanna put it in its own file; if it's only used in one place I like to define it where it's used, so it's easy to find. So is it cool and good to just chuck this class underneath my ViewController class in the same file? I know in some languages that's not all that popular but it does seem like Xcode makes it a little easier to navigate long files. The more languages I learn the more I find I want to learn the the sort of style/housekeeping practices early on but a lot of tutorials don't really focus on that. The guy who started this project also uses 4 spaces for indenting so I'm suspicious about how much I want to trust his way of doing stuff (while obviously still trying to maintain consistency in the project)
|
# ? Nov 21, 2020 19:43 |
|
|
# ? Apr 19, 2024 22:39 |
|
prom candy posted:So is it cool and good to just chuck this class underneath my ViewController class in the same file? I know in some languages that's not all that popular but it does seem like Xcode makes it a little easier to navigate long files. The more languages I learn the more I find I want to learn the the sort of style/housekeeping practices early on but a lot of tutorials don't really focus on that. The guy who started this project also uses 4 spaces for indenting so I'm suspicious about how much I want to trust his way of doing stuff (while obviously still trying to maintain consistency in the project) I would only do this if this particular subclass will never be used elsewhere. if there's a chance of reuse elsewhere in the codebase, make a new file. re: long files, the last two professional codebases I've worked with have each had linting rules against long files, so take that as you will. Fate Accomplice fucked around with this message at 19:55 on Nov 21, 2020 |
# ? Nov 21, 2020 19:52 |