I have a NSSize variable
var originalselectedimagesize:NSSize
if(originalselectedimagesize == nil)
{
}
I'm trying to check if NSSize is set? But i keep getting the following warning.How can i check if the value of NSSize is changed?
h(aka 'CGSize') to 'nil' always returns false
Because from the declaration, NSSize is not an optional. So checking a non-optional value for nil always return false.
In case if you have the following, then you won't get the warning.
var originalselectedimagesize:NSSize?
if(originalselectedimagesize == nil)
{
}
You can declare originalselectedimagesize
as NSSize?
( Optional
type of NSSize
), and set it to nil
. Then, you can check if it has value like this:
var originalselectedimagesize: NSSize? = nil
// what ever...
// check for value
if let size = originalselectedimagesize {
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.