Thiemo Krause Thiemo Krause - 5 months ago 7
iOS Question

Swift Cannot invoke 'someFunction' with an argument list of type '(SomeType, Block (($T9) ->

I'm working on an iOS Project which is using Swift and the Firebase API.

Somehow I'm getting the following error on this query:

ref.queryOrderedByKey().queryLimitedToFirst(limit as UInt)
.observeSingleEventOfType(FEventType.Value, withBlock: {
snapshot in

var n = News(
snapshot.key,
snapshot.value["value1"] as? String,
snapshot.value["value2"] as? String,
snapshot.value["value3"] as? Int)

result!.append(n)
})


The error:


Cannot invoke 'observeSingleEventOfType' with an argument list of type '(FEventType, withBlock: (($T9) -> ($T9) -> §T8) -> (($T9) -> ($T9) -> §T8)'


I'm pretty sure it is because the compiler is not recognizing the block or the type of snapshot correctly, but I don't know how to fix this in combination with blocks.

Update:

The Objective-C Header for the called function looks like this:



  • (void) observeSingleEventOfType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block;



Answer

Try UInt(limit) in place of limit as UInt.

I'm not sure what type limit is in your case, but I was able to get a similar error when limit was an Int. Doing the replacement fixed the issue for me.

Comments