Saturday, June 13, 2026
HomeiOS Developmentios - Loop to verify matches in a number of arrays

ios – Loop to verify matches in a number of arrays

[ad_1]

I’ve 7 arrays of Strings.

var redArray : [String] = ["2022-07-13", "2022-07-14","2022-07-15"]
var blueArray : [String] = ["2022-07-13", "2022-07-14","2022-07-16"]
...
And 5 extra of the identical format

I am attempting to create a technique that may undergo seven arrays and work like the next one (instance under works for 2 arrays):

       if redArray.comprises(someDate) && blueArray.comprises(someDate)
        {
            return [UIColor.red, UIColor.blue]
        }
        else
        
        if redArray.comprises(someDate)
        {
            return [UIColor.red]
        }
        else if blueArray.comprises(someDate)
        {
            return [UIColor.blue]
        }

        return [UIColor.clear]

So it ought to discover matches of dates in arrays and return color names of arrays with this matches. In case there isn’t a match – a single color needs to be returned. It is simple to do it for 2 arrays. However I do not perceive how can I loop by means of 7 of them 🙁

After all, it may be accomplished manually. However I assume there have to be a wise technique to implement the loop – although I am not sensible sufficient to determine it out how.

P.S. I do not know, if it can be crucial, however the operate the place this methodology will probably be used is the next:

func calendar(_ calendar: FSCalendar, look: FSCalendarAppearance,eventDefaultColorsFor date: Date) -> [UIColor]?
    {
       ...
    }

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments