2017-07-25 112 views
-3

swift code迁移到backendless 4(SWIFT代码)

当我运行在上面的图象显示的代码,它显示了以下错误:

Value of type '[Any]' has no member 'data'

如何解决这个错误?谢谢你的帮助!

+2

1.请[编辑]你的问题,包括你的代码为文本,不作为一个图像。 2.在发布前请[在错误上搜索](https://stackoverflow.com/search?q=%5Bswift%5D+value+of+type+Any+has+no+member)。这已被多次报道。 – rmaddy

+0

删除'data'部分并尝试为'users.first'。它可以工作。 – adev

+0

感谢adev,它的工作原理。也感谢rmaddy指出我的错误。 – louistone

回答

0

新API返回[Any]?而不是BackendlessCollection?

// v3 
let withUser = users!.data.first as! BackendlessUser 
// v4 
let withUser = users!.first as! BackendlessUser 



完整的迁移指南:Migration from 3.x to 4.x

v3.0 = All SDK implementations use the BackendlessCollection class to represent a collection of data from the backend.

v4.0 = BackendlessCollection is completely eliminated. Instead the backend returns an array of objects ([Any] in Swift)

+0

感谢您的详细解答 – louistone