Answer the question
In order to leave comments, you need to log in
How to determine the type of a variable in swift?
Good afternoon / evening everyone, I’m studying swift and in parallel with the perfect soft framework, the question arose,
I want to move the variable to a function so as not to duplicate the code. in general, everything looks like this.
func setCookies () -> HTTPCookie {
var iLoveMyCookie = HTTPCookie(
name: "PerfectCookie",
value: "Perfect is awesome",
domain: "localhost",
expires: .relativeSeconds(60),
path: "/",
secure: false,
httpOnly: false
)
return iLoveMyCookie
}
Answer the question
In order to leave comments, you need to log in
func setCookies() -> HTTPCookie? {
let cookieProperties: [HTTPCookiePropertyKey : Any] = [HTTPCookiePropertyKey.name: "PerfectCookie",
HTTPCookiePropertyKey.value: "Perfect is awesome",
HTTPCookiePropertyKey.domain: "localhost",
HTTPCookiePropertyKey.secure: false]
return HTTPCookie(properties: cookieProperties)
}
You have indicated
return iLoveMyCookie. That's why the iLoveMyCookie function returns.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question