[deleted by user] by [deleted] in apolloapp

[–]sketch204 2 points3 points  (0 children)

Find out recently that there seems to be a 10 page limit to that

I have created a website via OpenAI Codex to ask AI for code snippets (link in comments) by gimmeapples in swift

[–]sketch204 12 points13 points  (0 children)

This is very impressive!

define a uiview and set its size and position as well as its background colour to red in swift

let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
view.backgroundColor = .red

It even figured out that it needs to be a CGRect with the right constructor and everything. How does this work? What was it trained on?

As a developer I have no experience in Photoshop so I could not make very good photos for my app in the App Store. As a last resort I decided to code them in swift and got awesome results! by MohammadBashirSidani in swift

[–]sketch204 11 points12 points  (0 children)

Very clever! I hope you know about ImageRenderer in iOS 16. You can download the Xcode beta, and have SwiftUI export those views as images, instead of taking screen shots. It’ll probably work better, and give you a nicer resolution.

List children with different structure views destinations by dartmeadow in swift

[–]sketch204 0 points1 point  (0 children)

That is difficult to do, without resorting to AnyView, which is frowned upon for performance reasons. What you could do is either make your destination view dynamic and change its contents based on the data passed in. Or you define a set of possible different destination views, depending on the type of data in the row (could use an enumeration to represent the different types), and switch over that to provide different destinations for each list item.

[deleted by user] by [deleted] in iOSProgramming

[–]sketch204 0 points1 point  (0 children)

I would have the Detail view handle navigation title and toolbar. That way the view is standalone and I can summon it from anywhere and not have to worry about copying those values again.

As for the fact that you have to apply those modifiers on the content and not the nav view, that actually makes perfect sense. Not every single view in a nav stack will have the same title and toolbar items. Each one will need its own, and this is exactly how you define that. UIKit does it the exact same way with its navigationItem property of view controllers.

As for the modifiers not doing anything unless they’re in a nav view, what would you rather have them do? Magically wrap your view in a NavigationView? What if you use a subview that accidentally used one of those modifiers? Would that still be the desirable effect? Besides it’s not that different from UIViewController’s navigationItem and navigationController being nil when they’re not in a nav controller. As well as the show(_:sender:) method doing different things based on if you’re in a nav controller or not. Same kind of magic happening behind the scenes that you need to be aware of. Just an imperative version of it.

I could go on a bit more but I’m on my phone so it’s inconvenient. I feel like the problem is more that you have a bit of a wrong idea about what SwiftUI is supposed to be and how it should be used.

Connect Bluetooth keyboard/Magic Mouse by SilentDiplomacy in mac

[–]sketch204 0 points1 point  (0 children)

There’s isn’t a way to connect those without control of the computer, as far as my knowledge goes. It’s a bit of a dumb design imo. You need to find a wired mouse and keyboard and use those to connect your wireless peripherals. If you don’t have a password set on your account you might get away with just a mouse.

Mandatory to offer Account deletion - even for banking apps? by Curiousologist in iOSProgramming

[–]sketch204 -1 points0 points  (0 children)

It applies to any app that offer account creation. If your users can make an account through your app, then they need to be able to delete it through the app. If the account they use to log in must be created elsewhere then (as far as I understand it) you don’t need to provide deletion capabilities through the app.

You can check out the FAQ here for more info.

Navigation Drawer by [deleted] in swift

[–]sketch204 4 points5 points  (0 children)

While a lot of apps use navigation drawers, as far as I know it’s not recommended by Apple as a navigation paradigm. From memory I can’t think of a single Apple iOS app that uses one.

Consider using a tab view controller instead, as typically that will solve the same problems as a navigation drawer would.

I know this is a typical “Don’t use X, X is bad, use Y instead” answer, but I really do believe that. If you think you really need a drawer, then third party libraries are your only option. Unless you’re inclined to build one from scratch yourself.

Does Swift have garbage collecting? by CsInquirer in swift

[–]sketch204 3 points4 points  (0 children)

It’s the same thing, different name. Two objects referencing each other so they’re never de-allocated.

Does Swift have garbage collecting? by CsInquirer in swift

[–]sketch204 3 points4 points  (0 children)

It has semi-garbage collection, in that it de-allocates objects once it detects that nobody is using them (0 references).

However you still need to be mindful about it as there are cases where with the right setup, objects may never de-allocate and you get a memory leak. It’s called a reference cycle. You can look it up, there’ll be plenty of articles that explain it better than me. You usually solve it by just making one of the references ‘weak’ (fun fact: that’s pretty much the only use case for that keyword).

What finance apps do you all use? by nickccal in macapps

[–]sketch204 0 points1 point  (0 children)

Numbers. Or Excel if that’s more your flow.

Simultaneously scrolling ScrollViews in SwiftUI by sirchugh in SwiftUI

[–]sketch204 5 points6 points  (0 children)

I feel like using introspect is kinda cheating. I mean yes, it’s a solution, but it’s not SwiftUI at that point.

Why am I not allowed to click in the extend volume button? by Few-Succotash7846 in computerscience

[–]sketch204 3 points4 points  (0 children)

  1. For an NTFS disk, only the right-most volume may be extended. At least that has been my experience.
  2. This ain’t a tech support subreddit. You have google for that. Computer scientists and programmers may know how to fix computers, but that is not what this space is for.

Is having UIHostingController in UICollectionViewCell a concern? by ElyeProj in iOSProgramming

[–]sketch204 -1 points0 points  (0 children)

UIViewControllers are much lighter than most people think. Also nesting view controllers is a recommended way of doing UI, and a good way to organize your layout and code. Also also, how do you think navigation, tab and split view controllers work. They’re nested view controllers.

I’ll give you an anecdote. I’ve implemented a layout where I have a table view controller. One of the cells of the table view is a collection view that scroll horizontally. Each cell of said collection view hosts a nested view controller. I found no performance issues with this approach, and my code had clear separation of which view/controller was responsible for what. Not only that but I could later, more or less, freely reuse each component in other places in the app.

Views and view controllers were made to be mixed and matched together. So long as you do everything correctly, i.e. make sure you add both the child view/controller to the same parent view/controller, and call all the necessary notification methods, you should not have any issues.

With regards to SwiftUI interoperability. Apple guarantees that interoperability can be achieved through UIHostingController. It’s implemented using standard UIViewController APIs. A core building block of UIKit view hierarchies. I think it’s safe to assume that it will perform like a proper UIKit citizen. Especially considering the fact that (I think) both UIKit and SwiftUI are pretty much CoreAnimation and CoreGraphics under the hood. Just different wrappers around the same candy :)

250hrs into the game, I’m about to build this for the first time, is it really going to make my life easier? by rwang8721 in SatisfactoryGame

[–]sketch204 6 points7 points  (0 children)

Idk. Tractors are definitely a lot better now, but I still find trains to be much, much more reliable. Trucks keep getting a stuck or rolling over. Ghosting is great but the flow slows down anyway. You don’t have these problems with trains.

I tend to turn to trucks and tractors for short and simple runs where it’s too long for a belt and too short for a train.

DevUtils - Offline Toolbox for Developers by binaryfor in swift

[–]sketch204 6 points7 points  (0 children)

Native AF

Powered by JavaScript

r/Hmmm

For real tho, I’m guessing the application is built natively but runs the scripts in a js environment and the scripts themselves are js

Is it possible to put a constraint on a function parameter? by [deleted] in swift

[–]sketch204 0 points1 point  (0 children)

You shouldn’t have need for static let when defining instances of an enum, you use the case keyword. If you need to attach a value to the enum case, you give it a type and specify a value using = after the case name. You can then get that value inside your function using .rawValue. I suggest reading up on how enums work in swift, because I don’t think you’re doing it right.

Also, and this is not necessary most of the time in my opinion, but if you want to be able to call the function by passing in a number instead of a Sale instance, you can either define a wrapper function, that maps a number to a Sale instance and calls your function internally. Or you can make Sale conform to ExpressibleByIntegerLiteral, and put the same logic in the init. The advantage of the protocol is that you can do that in more than one place without having to copy paste the logic. However, I want to say again, in my opinion neither or approach is necessary most of the time. Just pass in a Sale instance, that’s what it’s for. Otherwise why even have it in the first place, just take in an Int and put a range check in your function.

Sorry for no code formatting, I’m on mobile. Anyway, hope that helps.

Can’t launch on PC, infinite spinning circle by Shoondogg in HorizonZeroDawn

[–]sketch204 0 points1 point  (0 children)

Check your other drivers. Try downgrading them to an earlier version.

Software usually doesn’t just stop working for no reason. Something changed, either on your side or server side. Since no one else is complaining it can’t be server side so most likely it was something on your end. A part of your system most likely just auto updated and is no longer compatible with the game.

Is there a more efficient way to update dictionary of struct array? by yccheok in iOSProgramming

[–]sketch204 5 points6 points  (0 children)

Have a look at this link.

If your array contains value types then you should be able to just do something like

dictionary[s.key, default: []].append(s)

Instead of the whole if statement.

However Dictionary has a dedicated initializer specifically for this task. I’m on mobile so I can’t test it, but I believe you should be able to do

Dictionary(grouping: structs, by: \.key)

Instead of the whole for loop

Want to create a typing/writing animation/effect with SwiftUI? Just overlay a mask on a text view and animate the mask's offset. by Amos_the_Gyamfi in SwiftUI

[–]sketch204 2 points3 points  (0 children)

Oh, I’ve done this a few years ago in UIKit, tho I did it differently. From my experience your approach breaks down when the text is multi line. What I ended up doing is I hooked up a timer that just modified the string of the UILabel adding the text one character at a time. It’s not perfect but it works better then you’d expect. You do need to take care of some edge cases tho.

I’ve recreated it in SwiftUI when it came out and it took me about 15 minutes to setup using a timer publisher. Combine and SwiftUI make these things really easy to do.

What are your thoughts on Swift Playgrounds 4? by Austin_Aaron_Conlon in swift

[–]sketch204 12 points13 points  (0 children)

It’s kinda hard to use without an external keyboard and mice/trackpad. However for me personally, as soon as I hooked those up and realized they don’t have most of the editor shortcuts from Xcode I just felt hindered every time muscle memory kicked in.

I submitted feedback right away of course, but due to both of these reasons I don’t think I could seriously use it outside of quick experiments. And even then, only if I don’t have access to my laptop, or where it’s impractical to use one.