Sunday, 23 February 2020

Create a singleton class in swift

Help : Link

class PurchaseManager{

static let shared = PurchaseManager(productID:"PrductIdentifier",isPurchased:true)
let productID:String
private var isPurchased = false;

private init(productID:String,isPurchased:Bool){
self.productID = productID
self.isPurchased = isPurchased
}

func isViewAllowed()-> Bool{
return self.isPurchased
}

}

print("is allowed \(PurchaseManager.shared.isViewAllowed())");

No comments:

Post a Comment