I am very new to Swift, I am converting my Objective-C code to Swift these days.
I declared these properties:
private var startLocation: UInt?
private var rangeIndex: UInt?
private var transaction: Array<Dictionary<String, UInt>>?
var location: UInt?
While attempting to add a Dictionary type into the transaction array, the compiler warns me.
Cannot invoke 'append' with an argument list of type '([String: UInt?])'
func beginTransaction() -> Void {
var transaction: Dictionary = ["rangeIndex": self.rangeIndex,
"location": self.location,
"startLocation": self.startLocation]
self.transaction?.append(transaction) //Warn: Cannot invoke 'append' with an argument list of type '([String: UInt?])'
}
Add
!toself.rangeIndex,self.locationandself.startLocationas an Implicitly Unwrapped Optional, the warning will then disappear.