Skip to content

Instantly share code, notes, and snippets.

Gustavo Rago grago

  • Blink+
  • Ciudad de Buenos Aires
Block or report user

Report or block grago

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@grago
grago / extension.swift
Created Dec 14, 2018
[Extension - Decoding JSON from your bundle] #ios #swift
View extension.swift
extension Bundle {
func decode<T: Decodable>(_ type: T.Type, from filename: String) -> T {
guard let json = url(forResource: filename, withExtension: nil) else {
fatalError("Failed to locate \(filename) in app bundle.")
}
guard let jsonData = try? Data(contentsOf: json) else {
fatalError("Failed to load \(filename) from app bundle.")
}
@grago
grago / uiapplication.swift
Last active Dec 10, 2018
[Link to subscription and app settings] #ios
View uiapplication.swift
extension UIApplication {
class func openAppSettings() {
guard let url = URL(string: self.openSettingsURLString) else { return }
self.shared.open(url, options: [:], completionHandler: nil)
}
class func openSubscriptionManagement() {
guard let url = URL(string: "itms://apps.apple.com/account/subscriptions") else { return }
self.shared.open(url, options: [:], completionHandler: nil)
}
You can’t perform that action at this time.