Home > Software design >  How can I let users add to lists
How can I let users add to lists

Time:10-19

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?

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

CodePudding user response:

Use an Array instead:

var reminders: [Reminder] = []

if !reminders.isEmpty {
    // if user has inputed data show the reminders
} else {
    // if not show nothing
}
  • Related