Thiemo Krause Thiemo Krause - 1 year ago 75
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.value["value1"] as? String,
snapshot.value["value2"] as? String,
snapshot.value["value3"] as? Int)


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.


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

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download