Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: arc4random to randomElement because arc4random is a deprecated method in swift #350

Merged
merged 3 commits into from
Oct 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ class CustomCalendarExampleController: DayViewController {
let duration = Int.random(in: 60 ... 160)
event.dateInterval = DateInterval(start: workingDate, duration: TimeInterval(duration * 60))

var info = data[Int(arc4random_uniform(UInt32(data.count)))]
var info = data.randomElement() ?? []

let timezone = dayView.calendar.timeZone
print(timezone)

info.append(dateIntervalFormatter.string(from: event.dateInterval.start, to: event.dateInterval.end))
event.text = info.reduce("", {$0 + $1 + "\n"})
event.color = colors[Int(arc4random_uniform(UInt32(colors.count)))]
event.isAllDay = Int(arc4random_uniform(2)) % 2 == 0
event.color = colors.randomElement() ?? .red
event.isAllDay = Bool.random()
event.lineBreakMode = .byTruncatingTail

events.append(event)
Expand Down Expand Up @@ -160,13 +160,13 @@ class CustomCalendarExampleController: DayViewController {
}

private func generateEventNearDate(_ date: Date) -> EventDescriptor {
let duration = Int(arc4random_uniform(160) + 60)
let duration = (60...220).randomElement()!
let startDate = Calendar.current.date(byAdding: .minute, value: -Int(CGFloat(duration) / 2), to: date)!
let event = Event()

event.dateInterval = DateInterval(start: startDate, duration: TimeInterval(duration * 60))

var info = data[Int(arc4random_uniform(UInt32(data.count)))]
var info = data.randomElement()!

info.append(dateIntervalFormatter.string(from: event.dateInterval)!)
event.text = info.reduce("", {$0 + $1 + "\n"})
Expand Down