Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I let users add to lists

In the Reminders app on iOS you can add a new reminder then it will add all the info you input to the reminders list. So I know a very long and inefficient method of doing this and I thinking there must be an easier way to do this.

Here’s The Long and inefficient way

var reminder1: String?
var reminder2: String?
// and so on and so on...

if (reminder1 != nil) && (reminder2 != nil) {
// if user has inputed data show the reminders
// if not show nothing
}

But how can I do this so I don’t have to create hundreds of variables?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

if it helps what I need for each reminder here it is: Title, subtitle, description, reminderIcon, reminder icon colour, startTime, endTime, group (as in what folder/collection of reminder this is), group icon and group icon colour

>Solution :

Use an Array instead:

var reminders: [Reminder] = []

if !reminders.isEmpty {
    // if user has inputed data show the reminders
} else {
    // if not show nothing
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading