I'm converting Swift 2 code that compiles and runs to Swift 3 and am getting the following error:
'Int1' is not convertible to 'Bool'
The code is as follows:
isUpdated = sharedInstance.database!.executeUpdate(
"UPDATE Coin_Table SET upgrade=?, grade=?, WHERE coin_id=?",
withArgumentsInArray: [
coinInfo.upgrade, (coinInfo.grade != nil) ? coinInfo.grade! : NSNull(),
coinID])
The code above is using FMDB with the method defined in FMDB.h as
- (BOOL)executeUpdate:(NSString*)sql withArgumentsInArray:(NSArray *)arguments;
When compiling my code above it flags the "(coinInfo.grade !=" and gives the error.
I tried simplifying it to see if it would still happen:
let theArray: NSArray = [true ? "foo" : NSNull()]
and still get the same error, this time it flags the "true".
I've done a bunch of searches on this and haven't found anything close other than https://bugs.swift.org/browse/SR-2372 but that is an issue with tuples which I wouldn't think would affect my code.
Can anyone shed some light on this or suggest a workaround if it is a compiler bug?
Thanks
As you wrote yourself your issue is the same as a one described here. Bugs happens ))
Why not just to use a temporary variable to fix it:
let hasGrade: Any = (coinInfo.grade != nil) ? coinInfo.grade! : NSNull()
isUpdated = sharedInstance.database!.executeUpdate(
"UPDATE Coin_Table SET upgrade=?, grade=?, WHERE coin_id=?",
withArgumentsInArray: [
coinInfo.upgrade, hasGrade,
coinID])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With