Reputation: 71
Here is my code:
func onDoubleTap(sender:AnyObject) {
var StringBool = Swapper.getSwapperValue
if StringBool == "false"{...}
Swapper
is another class, subclassing NSObject
. getSwapperValue
is function, which returns a false
value of variable. But with this code, I get an error: Binary operator '==' cannot be applied to operands of type 'Swapper -> () -> NSString' and 'String'
Upvotes: 0
Views: 412
Reputation: 86651
Looking at the error message
'Swapper -> () -> NSString' and 'String'
The type of the right side of ==
is String
, the type of the left side is Swapper -> () -> NSString
which is a function type - not a string of any sort. Functions in Swift are first class types which means you can treat them like an ordinary variable and my guess is that that is what you are doing - Swapper.getSwapperValue
is a function not a property. Try writing
var stringBool = Swapper.getSwapperValue()
or if Swapper is a class and getSwapperValue
is not a class function
var stringBool = Swapper().getSwapperValue()
Upvotes: 1
Reputation: 71
So, i resolved my problem here:
I created a variable in NSObject class named swapper1.
and here's my code: var swapa = Swapper().swapper1
and convert same.
Upvotes: 0