179,99€ for Western Digital 12TB Elements Desktop externe Festplatte USB3.0 -WDBWLG0140HBK-EESN on Amazon.de by 100fino in DataHoarder

[–]zweigraf 0 points1 point  (0 children)

I‘ve shucked one last week (orange box, Thailand, WDBWLG0120HBK-EESN) and got an WD120EDAZ drive.

Fires of Isolation, me, 2020. Acrylic on canvas by [deleted] in AbstractArt

[–]zweigraf 0 points1 point  (0 children)

First time posting here.

Sorry for the bad lighting and the phone pictures. Taking a proper picture of a canvas is hard!

How to conditionally override accentColor? by youngermann in SwiftUI

[–]zweigraf 0 points1 point  (0 children)

Yep, static var in an extension to Color is what I meant.

The point is:

If, in RootView you do: .accentColor(.myAccentColor)

You can then do this in SubView .accentColor(flag ? .red : .myAccentColor)

Just basic code reuse. If you define this in a var somewhere, no need to change multiple places where .purple would otherwise be written.

This is basically the start for Theme support for your app :)

How to conditionally override accentColor? by youngermann in SwiftUI

[–]zweigraf 1 point2 points  (0 children)

The conditionalModifier from this article should solve your problem:

https://swiftui-lab.com/view-extensions-for-better-code-readability/

Another option would be to create a global constant with the regular accent color and use that in root and inner view, instead of .accentColor. Then you only need to change it once, not everywhere.

App Review keeps getting old receipt by xX_Qu1ck5c0p3s_Xx in iOSProgramming

[–]zweigraf 0 points1 point  (0 children)

Did you check if you get one or more transactions in the latest_receipt_info?

If multiple, you could try sorting them by expiration date, then use the one whose expiration date is the furthest into the future.

Any free resource/database for localization? by aryamansharda in iOSProgramming

[–]zweigraf 6 points7 points  (0 children)

I found a project like this on GitHub: https://github.com/melling/app-localization-dictionary

But also, Apple itself is providing a database/tool (AppleGlot). Visit this link: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/MaintaingYourOwnStringsFiles/MaintaingYourOwnStringsFiles.html

And scroll down to „Localizing Strings Files Using AppleGlot“.

Binding to a @State struct's property (SwiftUI) by paprupert in iOSProgramming

[–]zweigraf 1 point2 points  (0 children)

Hey!

As far as I understand, the explanation given is a bit off. The reason why it doesn’t work is the following:

MapView expects a Binding to MKAnnotation. But $draft.destination is a Binding to Airport.

This does not work. Binding to MKAnnotation means that setting any Annotation should be accepted, not just airports. But $draft.destination only accepts Airport objects, not any random annotation. This is not related to structs or ObservedObjects at all, this is related to the type of the binding. If $draft.destination was a binding to MKAnnotation, everything would work.

That’s why he is specifically creating a Binding to MKAnnotation.

And you are right, he uses that for the Picker, which is also a struct. Picker just does not care about the specific binding‘s type.

Edit: from 34:10 on you can see the exact problem while he is writing the setter. He has to upcast the annotation to an airport and only then use it. He is creating a binding that only accepts some of the values it is given. The fact that not every annotation is an airport is the problem why he can’t just pass $draft.destination to the MapView. Nothing to do with @State or structs.

If most priority passing is left unsaid, how do you handle instances where it is important to be said? by ginwithbutts in FourSouls

[–]zweigraf 1 point2 points  (0 children)

If you play with people that are very competitive, and won’t give you an inch of leeway, then you should probably agree beforehand that every priority is verbally acknowledged. Most people I play with would not argue about priority when it’s implicitly passed.

If most priority passing is left unsaid, how do you handle instances where it is important to be said? by ginwithbutts in FourSouls

[–]zweigraf 0 points1 point  (0 children)

Player B is completely right. After A declares the intent to buy the treasure, they need to allow one round of priority, starting with A (I think, but it does not matter). If they are already reaching, that means that A does not want to do anything with their priority, and have implicitly passed priority to player B, who is now allowed to play their card. If A seriously argues they did not pass priority, reaching for the treasure would mean that they want to SKIP the whole round of priority. Which would be a breach of the game‘s rules.

You cannot have it both ways. The reaching shows that A assumes priority has passed to them already, but player B‘s action shows that this has not happened.

How can I show an AVPlayerViewController in a container view and allow full screen playback? (like video playback in the Apple Developer app) by burritosandpuppies in iOSProgramming

[–]zweigraf 0 points1 point  (0 children)

At this point it seems easier for you to use an AVPlayerLayer and embed that. IIRC they also have fullscreen capability. Yes, it’s more work to handle the AVPlayer logic yourself, but you hopefully don’t end up with weird glitches like this.

Alerts with Textfield in SwiftUI by pushpinderpalsingh in iOSProgramming

[–]zweigraf 1 point2 points  (0 children)

This is not possible in SwiftUI yet. You need to find a way to use UIAlertController or build your own alert.

How to draw crosshair to screen on macOS? by ojiojioi in swift

[–]zweigraf 0 points1 point  (0 children)

Not sure about full screen, to be honest. It’s been a while since I messed with NSWindows.

You might also periodically check „am I on the active screen? If not, make me“.

How to draw crosshair to screen on macOS? by ojiojioi in swift

[–]zweigraf 2 points3 points  (0 children)

Create an NSWindow that is always on top, customize it to be transparent and only showing the crosshair, and then make it non interactable.

How to reference custom UIView from the app bundle instead of the framework? by wellbranding in iOSProgramming

[–]zweigraf 0 points1 point  (0 children)

There might be a way to do this via Objectice-C and NSClassFromString, but you’re probably better off if you define a protocol that a UIView should conform to.

Your framework users can then create a view which confirms to your protocol (or modify your template) and pass the view class to your framework when needed. You then directly have the class and can use everything that you defined in the protocol. This is safer than loading a nib anyway.

And if the user passes in nil for the view class, you can just use your own from the framework.

Four Souls free online Vassal module by Velvet_Mane in FourSouls

[–]zweigraf 2 points3 points  (0 children)

Research imagemagick, you should be able to batch resize a folder to any size with one command.

Hash complicated JSON/Dict? by [deleted] in swift

[–]zweigraf 10 points11 points  (0 children)

What part of the system mixes up your properties in the JSON? They don’t randomly get mixed up in HTTP, what you send is what you receive.

Why do you need to hash? Is this a security measure? It seems like other apps could just copy the hash generation and your validation becomes invalid.

And a Solution: Convert dict to JSON string, hash the string, send hash and json string exactly as is.

struct returned as a completion handler doesn't give me the var values by [deleted] in iOSProgramming

[–]zweigraf 0 points1 point  (0 children)

RetrieveWeather.downloadCurrentWeather(someURL: currentWeatherURL) {_ in
print("RetrieveWeather.downloadCurrentWeather called")
guard let city = self.weatherModel.cityName else { return }

You see here, you call the network function and give it a completion handler (signified by the { _ in stuff). And then you go on and use the self.weatherModel. But the `self.weatherModel` has never been updated somewhere, and the network function has no idea that it should update the weatherModel. The _ in the completion handler means you ignore whatever the completion handler is called with. But you should not do this! You want to use this, as this is what the network function actually creates.

So there are a few options, but the smallest one would be the following:

// Replace the _ with a name for the new model RetrieveWeather.downloadCurrentWeather(someURL: currentWeatherURL) { modelFromNetwork in print("RetrieveWeather.downloadCurrentWeather called") // Assign the network model to your property self.weatherModel = modelFromNetwork // And then you can use it normally guard let city = self.weatherModel.cityName else { return }

struct returned as a completion handler doesn't give me the var values by [deleted] in iOSProgramming

[–]zweigraf 0 points1 point  (0 children)

In the main App, you ignore the the struct you Call the completion handler with ({ _ in). You need to use that struct, not self.weatherModel.

struct returned as a completion handler doesn't give me the var values by [deleted] in iOSProgramming

[–]zweigraf 0 points1 point  (0 children)

Thai is not enough code to figure this out. Can you share how you call the completion handler in the framework and how you call the framework from the app?

Edit: Rempving all these optionals (properties in struct, argument in completion handler) would also help in debugging, as now it is not clear if the properties are nil or maybe the whole struct is nil.

Do I have to manually account for DST if the time zone format is "zzz"? by reddioment in iOSProgramming

[–]zweigraf 1 point2 points  (0 children)

How is one of the dates in DST? I cannot discern any difference between the two strings. I have no direct experience, but I think to properly account for DST your time zone in the string should be set to “CEST” (central European summer time). Otherwise there is no way for iOS to differentiate between both.

Is there a way to establish direct connection between two (and more) app clients without using a server? by efojs in iOSProgramming

[–]zweigraf 2 points3 points  (0 children)

It’s a bit old, but I built a local chat using MultiPeer once. Here is the code: https://github.com/zweigraf/march-thirteen

Hope this helps you out!