|
pokeyman posted:My guess is you're getting tripped up by the scroll view's not having an intrinsicContentSize, so it ends up having zero height. Try making a UIScrollView subclass, override intrinsicContentSize to return contentSize, and then override contentSize to add a didSet observer that calls invalidateIntrinsicContentSize. Don't forget to set your scroll view to your new subclass. Neat, I don't really know what contentSize or intrinsic contentSize is but it gives me some stuff to learn about tomorrow. Thank you!
|
# ? Mar 16, 2021 00:47 |
|
|
# ? May 15, 2024 03:47 |
|
prom candy posted:Neat, I don't really know what contentSize or intrinsic contentSize is but it gives me some stuff to learn about tomorrow. Thank you! You're welcome! intrinsicContentSize in particular is worth internalizing because it's fundamental to how Auto Layout works, and trying to go around it (e.g. with hardcoded width and height constant constraints) can bring unnecessary pain.
|
# ? Mar 16, 2021 01:31 |
|
Any SwiftUI wizards in here? I’m trying to learn by converting an old Mac utility I use (a glorified timer) to SwiftUI but I’ve run into a brick wall on an esoteric but essential feature. The old app is a single window application with an URL scheme (appname://15) that can be used to change the timer. I've attempted to recreate the old URL Scheme functionality using the new onOpenURL SwiftUI method, but whenever the URL Scheme triggers, the app opens a new window and I can't figure out how to stop that from happening. Swift code:
Anyone know how I stop onOpenURL from launching new windows or force SwiftUI to do a single window Mac app? I'm converting the app specifically to learn SwiftUI, but if it's not possible to do this behavior in SwiftUI, I'm willing to mix and match in some AppKit code.
|
# ? Mar 16, 2021 04:52 |
|
pokeyman posted:You're welcome! intrinsicContentSize in particular is worth internalizing because it's fundamental to how Auto Layout works, and trying to go around it (e.g. with hardcoded width and height constant constraints) can bring unnecessary pain. Oh okay I kinda understood this without knowing what it was called or how to affect it. Now I have a better understanding of the content hugging/compression resistance stuff. Your solution worked perfectly as well, thanks! code:
prom candy fucked around with this message at 15:04 on Mar 16, 2021 |
# ? Mar 16, 2021 14:20 |
|
Siguy posted:onOpenURL problem If anyone's curious, after some Reddit/StackOverflow help, I ended up switching to the poorly documented handlesExternalEvents method for my WindowGroup. Then I was able to use onOpenURL within my ContentView to handle the URL Scheme events without new windows popping open. code:
|
# ? Mar 17, 2021 07:02 |
|
Siguy posted:If anyone's curious, after some Reddit/StackOverflow help, I ended up switching to the poorly documented handlesExternalEvents method for my WindowGroup. Then I was able to use onOpenURL within my ContentView to handle the URL Scheme events without new windows popping open. Nice! I've not done much with SwiftUI yet so accumulating these gotchas will no doubt come in handy once I dive in. For what it's worth, you can replace e.g. Set(arrayLiteral: "pause") with, as you might guess, an array literal: ["pause"]. The latter just calls the former, but it's more idiomatic.
|
# ? Mar 17, 2021 07:17 |
|
pokeyman posted:For what it's worth, you can replace e.g. Set(arrayLiteral: "pause") with, as you might guess, an array literal: ["pause"]. The latter just calls the former, but it's more idiomatic. Thanks. That felt wonky. I've been away from Apple land for a couple years and it's frankly shocking to return and realize how shallow the documentation is compared to other languages. I kept looking at the Set documentation and thinking "Where's the part that shows you ten different ways to create a Set like you get in the Rust or Ruby documentation?"
|
# ? Mar 17, 2021 19:31 |
|
I want to make some kind of object that I can use to quickly access my app's colors and fonts, something like Styles.fonts.sansRegular(16) (returning a UIFont) or Styles.colors.lightText (returning a UIColor) Is this a thing that people do or am I just trying to shoehorn web stuff into iOS? If it is cool to do this should I just use enums with static properties/funcs?
|
# ? Mar 19, 2021 14:59 |
|
Yep people do that. There are tools that will autogenerate those types for you based on asset catalogs and resources, such as SwiftGen, if that sounds useful. And yep, caseless enums with static func/var sounds legit.
|
# ? Mar 19, 2021 16:36 |
|
none of the legal folks can tell me what we should or shouldn't track to comply with the IDFA changes. I'm about to shut off all tracking and then get fired because number go down.
|
# ? Apr 2, 2021 17:08 |
|
KidDynamite posted:none of the legal folks can tell me what we should or shouldn't track to comply with the IDFA changes. I'm about to shut off all tracking and then get fired because number go down. I spent far too long trying to figure out if Awful.app "tracks users" by requiring a user identifier to log in and then letting you write posts associated with that identifier. At one point I looked at a variety of seemingly adjacent apps (Reddit clients, Tumblr clients) and some listed nothing and others listed a lot. Kind of a crapshoot.
|
# ? Apr 2, 2021 21:51 |
|
With UICollectionViewCompositionalLayout does anyone have a nice way of defining and sharing layouts or individual sections layouts across their app? I have one screen that's built of a few different section layouts, and then another screen using completely different data that nonetheless wants the exact same section layouts as one of the sections from that first screen. I'm trying to think of a good way to share that code since it doesn't really fit into an object. I guess maybe subclassing NSCollectionLayoutSection and then setting up the items/groups/supplementary views within that class?
|
# ? Apr 3, 2021 18:10 |
|
I’m trying to do something I think should be supported natively but I can’t figure out... I have a list of currency values that have an amount and currency code. Like 800 USD or 700 EUR. I want to print each value properly formatted using a NumberFormatter with currency style, like “$800.00” or “€ 700.00”. But it seems like currencySymbol is a property of the NumberFormatter, not something you pass when you format the value. So it seems like I need to create a new NumberFormatter for each different currency, and switch to the the appropriate one depending on the currency of the value. Am I missing something obvious? Edit: after another day of playing with SwiftUI, my mistake was making any assumption about there being built in support for anything. smackfu fucked around with this message at 23:10 on Apr 6, 2021 |
# ? Apr 6, 2021 13:35 |
|
smackfu posted:I’m trying to do something I think should be supported natively but I can’t figure out... I have a list of currency values that have an amount and currency code. Like 800 USD or 700 EUR. How much have you looked into localization? I think in this case you might want localizedString(from:number:), although, might want to look at some examples to see if it's what you need. Having a pre-existing list of currency codes might require your own lookup table, though.
|
# ? Apr 7, 2021 14:58 |
|
Ok, it's 2021, so time for one of my every 5 year attempts to get things set up and develop toy iPhone apps. ...what's the current recommended set of tutorials for 2021 Swift + iPhone development?
|
# ? Apr 8, 2021 00:13 |
|
ulmont posted:Ok, it's 2021, so time for one of my every 5 year attempts to get things set up and develop toy iPhone apps. I’m enjoying LearnAppMaking.com The demo projects are useful and it’s not a bunch of videos that you follow along with, but pages of well written instructions and explanations. You can end up copy+pasting code into places, but that’s up to you and the site explains what it does and why very clearly. Not cheap at all tho: $99 for the developer courses. There’s also the udemy course by Angela Yu that you can usually get for ten bucks or so. That’s also good, but less focus on coding and more on storyboards, which wasn’t what I was looking for. I haven’t checked recently, but don’t think there’s much SwiftUI in that course. There’s also a free guide on hackingwithswift.com. That site is good and I end up there often via google searches. Same for raywenderlich.com e: oh whoops, Apple also have tutorials: https://developer.apple.com/tutorials e2: hate to post so much, but I want to add that awful.app is on GitHub, there’s lots of ways to contribute to it and you get real feedback from people that use it daily. So playing with that might hold your attention more than creating apps using tutorials. That’s been my experience commie kong fucked around with this message at 01:07 on Apr 8, 2021 |
# ? Apr 8, 2021 00:45 |
|
The Apple SwiftUI tutorial wasn’t as good as I hoped. It seemed like it was more interested in showing a bunch of different topics than having a coherent path. Like drawing paths doesn’t seem that useful? And they started having you copy and paste a lot of code as it went on without really explaining it.
|
# ? Apr 8, 2021 02:42 |
|
smackfu posted:I’m trying to do something I think should be supported natively but I can’t figure out... I have a list of currency values that have an amount and currency code. Like 800 USD or 700 EUR. Changing the currency code on a formatter works fine. Output is automatically localised based on the `.locale` property of the formatter. code:
dc3k fucked around with this message at 06:26 on Apr 8, 2021 |
# ? Apr 8, 2021 06:21 |
|
I might as well point out that NSDecimalNumber is bridged to Swift as Decimal, and it's a solid 30-40% easier to use too!
|
# ? Apr 8, 2021 06:57 |
|
I have a singleton class that keeps track of active file uploads in my app. A user can start an upload from one section of the app and then gently caress off elsewhere and the upload should just continue chugging along. However in certain spots in the app I need to show how many uploads there are, overall progress, etc. At some point I'll probably have to add cancelation too. Anyway, I'm thinking the view controllers that need this info should be able to tap into it so that I'm not creating any tight coupling between the ActiveUploads class and whatever view controllers are interested in its data. I was thinking Combine might be a good solution to this, but after reading/watching some tutorials I'm not sure I really get the point or see the advantage of using it vs. just broadcasting notifications using NotificationCenter. For example, I want to be able to let whoever's interested know when the number of active uploads changes, when the progress of an upload changes, or when the status of an upload changes. Is there a benefit to using Combine for this? It seems like in a lot of the tutorials I've looked at they're using NotificationCenter.Publisher to accomplish essentially the same thing as NotificationCenter.addObserver so I'm not sure if I'm understanding it right. Is NotificationCenter the right way to handle situations like this or is it better for my consuming classes to more directly subscribe to ActiveUploads (and if so I guess using Combine to create one or more custom publishers within ActiveUploads would be the way to do it. I'm also seeing a ton of talk about Combine in tandem with SwiftUI, am I wasting my time with it if I'm using UIKit?
|
# ? Apr 8, 2021 19:10 |
|
NotificationCenter would work, as would having some KVO-compliant properties on the singleton. In fact, if you're using OperationQueue, you already have a KVO-compliant property for numberOfOperations. Combine can make publishers out of KVO-compliant properties if you want Combine involved. And I think Combine would work great with UIKit, though it's not strictly necessary of course. Just make sure to touch UI from the main thread.
|
# ? Apr 8, 2021 19:28 |
|
I'm not using OperationQueue nor do I really know what it is but as usual from your answers there's another thread I can pull at, thanks! I haven't really done much with KVO either, I'll take a look and see if that would be a nicer way to manage this. A fun side effect of this is that I need these uploads to continue even if the app is backgrounded, and also after the uploads complete they need to fire off other API calls which in turn need to fire off other API calls and it sounds like OperationQueue may help with that. I'm also thinking I may just need to rearchitect some of this stuff so that the client is less responsible for all this orchestration after the file is uploaded.
|
# ? Apr 8, 2021 19:59 |
|
OperationQueue might not be helpful, just thought I'd mention it in case you were already using it. If you're hoping to keep running in the background, you'll be subject to short and undocumented time limits (~seconds up to a couple minutes). Make sure to take a task assertion (UIApplication calls this a "background task" and NSProcessInfo calls it an "expiring activity") while you're working so you don't get terminated unceremoniously. https://developer.apple.com/forums/thread/85066 is the bible here. To continue network activity while suspended (app process not running), you'll want a background URLSession. Not sure about triggering further API calls after a background session task completes though. I don't remember if your app will get to run in response to the background URLSession tasks completing. I'm almost certain you can't count on getting to run, even if you sometimes are. And you'll only get a few seconds. https://developer.apple.com/documentation/foundation/url_loading_system/downloading_files_in_the_background looks helpful, and some useful info at https://developer.apple.com/forums/thread/14855. Look for relevant WWDC videos too, last year had https://developer.apple.com/videos/play/wwdc2020/10063/ and head to https://asciiwwdc.com/ and search for e.g. URLSession, check out any video that sounds relevant.
|
# ? Apr 9, 2021 01:46 |
|
Thank you! I think we're going to have to move some of the file coordination to the server and use S3 notifications or something rather than relying on the client to kick off all the post-upload tasks. If we can at least just finish the upload if the user backgrounds the app that should be a good start. My suggestion to just tell the user to keep the drat app open is not being well received.
|
# ? Apr 9, 2021 03:39 |
|
That sounds like the right approach.
|
# ? Apr 9, 2021 03:43 |
|
So I'm working on this background uploading stuff and I'm at the point where I'm actually testing if the uploads continue in the background and it's all falling apart. A couple seconds after I put the app in the background I get this dump of errors:code:
|
# ? Apr 14, 2021 22:00 |
|
Huh, well interestingly the complete files are ending up on S3 so something else must be happening to cause the error. Edit: nvm that was just small files finishing before the transfer was interrupted prom candy fucked around with this message at 16:00 on Apr 15, 2021 |
# ? Apr 15, 2021 15:04 |
|
No brainwaves from me, sorry. I do know that having a debugger attached will mess with all kinds of timeouts and resource limits, but it looked like you were checking the console so that's probably not it.
|
# ? Apr 15, 2021 17:01 |
|
After even more checking it looks like even the large files are finishing (I was looking in the wrong bucket for them) so it might just be the debugger is sounding the "everything's ok" alarm
|
# ? Apr 15, 2021 17:43 |
|
I wonder if those console logs were announcing that your app has severed its (xpc?) connection with whatever daemon runs background URL sessions? Which would make sense as your app is being suspended.
|
# ? Apr 15, 2021 18:43 |
|
can y'all confirm for me that in ios 14.5 Settings>Privacy>Tracking "Allow Apps to Request to Track" is defaulted to off?
|
# ? Apr 29, 2021 14:31 |
|
KidDynamite posted:can y'all confirm for me that in ios 14.5 Settings>Privacy>Tracking "Allow Apps to Request to Track" is defaulted to off? Mine was set to on. Never touched it before now when I turned it off. All the individual app settings were set to off though.
|
# ? Apr 29, 2021 15:48 |
|
jabro posted:Mine was set to on. Never touched it before now when I turned it off. All the individual app settings were set to off though. interesting I don't remember setting my phone to off. apple has rejected my app saying i don't use requestTrackingAuthorizationWithCompletionHandler: while using app tracking transparency but it's in app delegate's application(_:didFinishLaunchingWithOptions:) and running it on the simulator the alert shows up. running it on my phone even after deleting and setting Allow Apps to Request to Track to on it just pops into the completion handler saying it was denied. i appealed but there's been no response. also number predictably went down and people are freaking out even after i explained it to them. fun times.
|
# ? Apr 29, 2021 16:24 |
|
Some of those settings get cached for awhile, even between reinstalls. Might try deleting app, enabling things in Settings.app, rebooting phone, then build and run?
|
# ? Apr 29, 2021 16:28 |
|
pokeyman posted:Some of those settings get cached for awhile, even between reinstalls. Might try deleting app, enabling things in Settings.app, rebooting phone, then build and run? i tried that and no luck. used an old iphone and was able to get it to show up.
|
# ? Apr 29, 2021 16:55 |
|
The other way of testing permission-based behaviours is to change your bundle ID temporarily for a test build.
|
# ? Apr 29, 2021 19:13 |
|
KidDynamite posted:can y'all confirm for me that in ios 14.5 Settings>Privacy>Tracking "Allow Apps to Request to Track" is defaulted to off?
|
# ? Apr 29, 2021 21:58 |
|
I noticed that Xcode.app was 29 loving gigabytes, so I dug down and found that the .platforms take up most of that. So I tried deleting the AppleTV and WatchOS platforms, but Xcode complains that they're missing when you load it up and you have to reinstall. Lame. I will never develop using those, so they're just going to take up >12GB of space for nothing.
|
# ? May 2, 2021 14:10 |
|
Yeah, I really wish you could delete all the poo poo from Xcode you don't need.
|
# ? May 2, 2021 21:16 |
|
|
# ? May 15, 2024 03:47 |
|
Plorkyeran posted:Yeah, I really wish you could delete Same
|
# ? May 4, 2021 04:20 |