import Foundation enum PremiumAccess { static let freeDishLimit = 15 static let freeFutureWeeks = 1 /// Free users get a taste of on-device ingredient generation; premium is /// unlimited. Counted per install via UserDefaults. static let freeIngredientGenerations = 3 private static let generationCountKey = "ingredient_generation_count" static func hasReachedFreeDishLimit(dishCount: Int, isPremium: Bool) -> Bool { !isPremium && dishCount >= freeDishLimit } static func canGenerateIngredients(isPremium: Bool) -> Bool { isPremium || UserDefaults.standard.integer(forKey: generationCountKey) < freeIngredientGenerations } static func recordIngredientGeneration() { let count = UserDefaults.standard.integer(forKey: generationCountKey) UserDefaults.standard.set(count + 1, forKey: generationCountKey) } }