Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check for NSDecimalNumber.zero() in Swift

Using 'num1' as a comparison reference to determine if 'num2' or 'num3' are zero. Have done this successfully in Objective-C, and am trying to do it in Swift:

let num1: NSDecimalNumber = NSDecimalNumber.zero()
let num2: NSDecimalNumber = NSDecimalNumber.decimalNumberWithString("0")
let num3: NSDecimalNumber = NSDecimalNumber.decimalNumberWithString("0.000001")

if num1.compare(num2) == NSOrderedSame {
    println("They match")
}

This attempt results in: "error: use of unresolved identifier 'NSOrderedSame'." What is the proper way to accomplish this in Swift? (Have searched the book and web, but missing something possibly obvious, thank you).

like image 486
H_H Avatar asked Jun 14 '14 19:06

H_H


1 Answers

Do you mean: num1.compare(num2) == NSComparisonResult.OrderedSame

like image 55
Christian Dietrich Avatar answered Oct 03 '22 00:10

Christian Dietrich