TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Having problems with Dates()

Forums > SwiftUI

Hello!

I am trying to create a simple "app". Goal of the app is to display the corect time, incremented by 20 minutes( 7:20, 7:40, 8:00 etc.) by moving a picker that is connected to an array of 20 items.

To explain it precisely. It's about a videogame, World of Warcraft, there is an live event where you have 20 mini bosses, each spawn at said intervals, 7:20, 7:40, 8:00 and so on. The order in which they appear is always the same but the time isn't. Event started today, first one appeared at 7:20, second one at 7:40.

Like I said, I created a picker that selects between these 20 bosses and changes the time by 20 minutes but obviously the timing is not right. Is there a way to sort this, to create a custom time frame. I've been checking Timers but I'm not sure they will work. Any help/advice would be much appreciated!

2      

I'm not entirely sure what you are trying to achieve here. You said they spawn in the same order. So basically a rotation of Boss1, Boss2 ... Boss 20, back to Boss1? And if that's the case, you want to be able to set the timer based on the boss you meet? So for example if you stumble on Boss15, you set it's time for now, and the others get their times updated 20 min sequentially?

Or is there some other way you want to track? Because ultimately, you can set the first timer for 20 min, and get it to repeat. Something you can do in the Clock app on your phone. Do you want to experiment replicating that?

If the first example is what you are going for, there are couple of ways to go about it. You might want to look at scheduling alerts. I recall Paul having given us one such tutorial in HWS UIKit edition, or might have been another book. But the topic might provide you with what you want.

2      

Hey @MarcusKay! Yes, after Boss 20 goes down, the list starts from Boss1 again. I want to get the exact time the future Boss1,2,3 or 4 will spawn. First Boss for this event poped up at 7:20 AM today, I want to know the exact time they appear in the future by selecting a certain boss. Hope that explains it a bit more and thank you for your reply!

2      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.