1)我想知道在类中使用静态属性传递数据是否可以。
例如:我使用swift类而不是Obj-C类创建一个类:
将此类存储在模型文件夹
中class Player {
static var playerName: String =""
static var score: Int = 0
static var Team: String =""
}
VC1中的。
我设置
Player.playerName ="Alexander"
VC2中的: 我访问它:
var strPlayerInAction = Player.playerName
2)如何声明静态类?
static class Player{
}
这样,我可以灵活地传递许多数据。但这会导致任何问题吗?
答案 0 :(得分:0)
您可以使用结构来实现您想要的效果。
struct Players {
static var playerName = "name"
}