Skip to content

Commit

Permalink
Replace an as! Int with if let ... as? Int
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio committed Aug 17, 2023
1 parent 9309952 commit f6876d0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class SessionManager {

if session.isEmpty {
var visitorInfo = visitorManager.getVisitorInfo()
visitorInfo["session_count"] = visitorInfo["session_count"] as! Int + 1

if let previousCount = visitorInfo["session_count"] as? Int {
visitorInfo["session_count"] = previousCount + 1
}

session = [:]
session["session_id"] = visitorInfo["session_count"]
Expand Down

0 comments on commit f6876d0

Please sign in to comment.