3
self.mapper.identityIdsForQuickbloxUserIds(userIDs.map{($0 as! NSNumber).unsignedLongValue}, completion: { identityIdsMapping, error in

无法转换调用结果类型“_?” 到预期类型'[UInt]'

userIDsNSSet

这是一个功能:

func identityIdsForQuickbloxUserIds(userIds:[UInt], completion:(identityIdsMapping:[UInt: String]?, error:NSError?) -> Void)

如何以正确的方式转换它?

这是为我返回的外部函数:

- (void)allDialogsWithPageLimit:(NSUInteger)limit
                extendedRequest:(QB_NULLABLE NSDictionary *)extendedRequest
                 iterationBlock:(void(^QB_NULLABLE_S )(QBResponse *QB_NONNULL_S response, NSArray QB_GENERIC(QBChatDialog *) *QB_NULLABLE_S dialogObjects, NSSet QB_GENERIC(NSNumber *) * QB_NULLABLE_S dialogsUsersIDs, BOOL * QB_NONNULL_S stop))iterationBlock
                     completion:(void(^QB_NULLABLE_S)(QBResponse * QB_NONNULL_S response))completion;

如您所见,我们从这里获得了 NSSet:

NSSet QB_GENERIC(NSNumber *) * QB_NULLABLE_S dialogsUsersIDs

该方法来自QuickBlox SDK

4

2 回答 2

1

示例 1:

这是一个简单的例子:

    identityIdsForQuickbloxUserIds([1,2,3]) { dictionary, error in


    }

示例 2:

    let x = NSSet(array: [1, 2, 3]).map { $0 as! UInt }

    identityIdsForQuickbloxUserIds(x) { dictionary, error in


    }
于 2016-04-19T17:36:13.340 回答
1

userIDs是可选的Set<NSNumber>?Set<NSNumber>所以如果首先使用这样的东西,你需要打开包装

var ids = userIDs?.map { $0.unsignedLongValue } ?? [UInt]()

...

identityIdsForQuickbloxUserIds(ids, ...)
于 2016-05-04T14:37:18.800 回答