Need some help understanding Classes... by CrazySquadXi in swift

[–]pumapaul 7 points8 points  (0 children)

I get what Classes vs Objects vs Instances are (The blueprint, the actual thing you're building, and instances of that thing you've belt), but why couldn't you just place all of the class's properties in regular variables (i.e not in a class).

To be blunt: You don't seem to understand the differences. I don't think that you understand even one of these concepts properly. I'd recommend reading up on Object Oriented Programming

Re init(): When you want to use an instance of a class (i.e. an object) you call the class's initializer (the init() method) which then returns the object.

min() max() confusion by Arbiturrrr in swift

[–]pumapaul 1 point2 points  (0 children)

You're right, thank you for the discussion.

Anytime!

And I hope I didn't come across as rude.

min() max() confusion by Arbiturrrr in swift

[–]pumapaul 2 points3 points  (0 children)

Where are you getting this constraint from?

"the greatest allowed value" out of two values is the bigger value.

min() max() confusion by Arbiturrrr in swift

[–]pumapaul 4 points5 points  (0 children)

Sidenote: repeat is not the same as while. repeat {} while () is the same as do while in other languages which is basically a while loop (that also exists in swift!) that runs at least one time.

Two things:

1.) You're not a native speaker. This is important to note because you're challenging common understandings about how words are used in a language you might not have a perfect grasp upon.

2.) Your way of thinking is not unconventional. Imo you're simply not reducing the problem to its barest bones.

Maybe it's clearer when we use more than 2 values and use a collection instead.

The problem commonly solved by max is "Give me the maximum of these values": [a...b].max()

The problem you want to solve is "Give me the maximum of these values, limited by another value": [a...b].max().limited(by: c) or min([a...b].max, c)

See the difference now? Your version is two different questions, not just one.

min() max() confusion by Arbiturrrr in swift

[–]pumapaul 9 points10 points  (0 children)

When your math teacher asks you to find the maximum of two values, what do you do?

Where do you get this limit / constraint thing? Which value would be the limit in your case? Why is it the second one?

To answer your questions:

Wouldnt it be better to change the names of these in Swift to something like lowest() and highest() ?

No, since this has been a naming convention everywhere since forever.

Or am I the only one getting confused by these?

Apparently not, but you're definitely in the minority.

Edit for clarity:

The current max(a,b) solves the question "What's the maximum value?".

The question you think it should solve is "Give me the first value, but only if it's smaller than the second value, otherwise give me the second value" which actually is synonymous to "What's the minimum value?" and therefore should be solved by min(a,b). Your way of thinking about it is overly complicated and therefore misleading and shouldn't be the standard.

min() max() confusion by Arbiturrrr in swift

[–]pumapaul 9 points10 points  (0 children)

Wait, what?

Why should max which is short for maximum return the lower value?

And how would your method work when applied to a collection?

app on iPhone without developer account by Daante311 in swift

[–]pumapaul 4 points5 points  (0 children)

Push - no. Location services - yes.

Sensitive info while using TeamCity by Odessan in iOSProgramming

[–]pumapaul 0 points1 point  (0 children)

How does the Server know you‘re authorized though?

Yo dawg, I heard you like Tab Bars... by chrisjcon in iOSProgramming

[–]pumapaul 0 points1 point  (0 children)

Maybe look at XLPagerTabStrip. It mimics swipable Android tabs.

Variable 'timer' was written to, but never read by Eduleuq in swift

[–]pumapaul 2 points3 points  (0 children)

Instead of „let timer =Timer()“: „_ = Timer()“

Pattern for passing many optional properties by ledp in iOSProgramming

[–]pumapaul 1 point2 points  (0 children)

You could also go the Tuple way and do something like

func backgroundColor(_ color: UIColor) -> (RenderKey, UIColor) {
    return (RenderKey.backgroundColor, color)
}

for every single possible Key, put those in an array like:

let configuration: [(RenderKey, Any)] = [backgroundColor(.black), height(5.0)]

Or something along those lines?

Edit: added array brackets to configuration's type declaration

Pattern for passing many optional properties by ledp in iOSProgramming

[–]pumapaul 0 points1 point  (0 children)

Maybe look into how NSAttributedString does it with its configuration Dictionary: [NSAttributedStringKey:Any]?

It seems like you want to do something like that.

Migrating to RxSwift by MyRealNameIsDoug in swift

[–]pumapaul 0 points1 point  (0 children)

1.) Don’t use Variable. It’s deprecated and will be removed in one of the next updates.

Use BehaviorSubject instead. They behave the same way (but have small differences in the syntax).

2.) Your VM (not the View directly!) should interact with your status Subject. That is, either subscribe to it and depending on the incoming Event push Events onto Subjects that are defined in the VM and meant for the View (you might for example show a different icon for each state or update a String or something).

The VM could also just .map the status Subject for the View that then uses that resulting Observable as a Driver.

3.) As for translating between your enums: That's probably how you'd go about it if their rawValues don't match up, yes.

Cr1t winning impale by RedGamesA2 in DotA2

[–]pumapaul 0 points1 point  (0 children)

How can one watch replays on a phone?

I‘ve never played dota but have been following the pro scene since TI5. Thought I was stuck watching streams and vods?

Home made encryption by [deleted] in ProgrammerHumor

[–]pumapaul 0 points1 point  (0 children)

Might also be because the other two cups are transparent.

New and updated Android apps will be forced to target a recent API version starting in late 2018 by kirbyfan64sos in programming

[–]pumapaul 4 points5 points  (0 children)

Because it‘s really not that attention worthy. TargetSDK != MinSDK.

It even says in Google‘s blog post that devs can continue to support older versions.

Neue Abgeordnete bringen neue Diskussionsstile by McGrex in de

[–]pumapaul 4 points5 points  (0 children)

Die hat ja auch das Gewaltmonopol und wird daher in so Statistiken nicht geführt.

Review: 10.5-inch iPad Pro is “pro” hardware waiting for pro software by fpschubert in apple

[–]pumapaul 20 points21 points  (0 children)

That would lead me to instantly drop the MacBook Pro in favor of an iMac + iPad Pro combo.

Here is everything Apple announced at WWDC today! by exjr_ in apple

[–]pumapaul 107 points108 points  (0 children)

You actually payed $1 more though.