Skip to content

Instantly share code, notes, and snippets.

View olivaresf's full-sized avatar

Fernando olivaresf

View GitHub Profile
@olivaresf
olivaresf / Apple_mobile_device_types.txt
Created November 4, 2021 01:48 — forked from adamawolf/Apple_mobile_device_types.txt
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
extension UserDefaultsStorage {
/// Previously stored migration data.
///
/// - From the cache, if available. The cache has the same lifetime as the session.
/// - If the cache is not available, try from UserDefaults, save to the cache.
/// - If UserDefaults doesn't have any data, then return `defaultStoreData` and save to UserDefaults.
///
/// - Returns: a struct describing model version, settings bundle and onboarding bundle.
private var storedMigrationData: MigrationData {
// the model version is stored if migrations are needed in the future
#warning("Can we inline this into UserDefaultsStorage or get rid of it entirely?")
private struct MigrationData: Codable {
var modelVersion: String
var settingsBundle: SettingsBundle
var onboardingBundle: OnboardingBundle
}
final class UserDefaultsStorage: Storage {
let modelVersion: String
let key: String
init(withKey: String, modelVersion: String) {
key = withKey
self.modelVersion = modelVersion
}
// SimpleMath
// Copyright (c) Filip Lazov 2020
// MIT license - see LICENSE file for more info
import Foundation
final class UserDefaultsStorage: Storage {
let modelVersion: String
let key: String
#warning("Documentation needs work.")
#warning("Who is calling `storedData`? Why is it private?")
/// What data?
/// - The cache, if available.
/// - If the cache is not available, try from UserDefaults
/// - If UserDefaults doesn't have any data, then return `defaultStoreData`
///
/// - Returns: a Store Data object?
private var storedData: StoredData {
struct Country {
var code: String?
var name: String?
var phoneCode: String?
var flag: UIImage? {
guard let code = self.code else { return nil }
return UIImage(named: "SwiftCountryPicker.bundle/Images/\(code.uppercased())", in: Bundle(for: MRCountryPicker.self), compatibleWith: nil)
}
init(code: String?, name: String?, phoneCode: String?) {
func setup() {
// Loading a JSON with our country list.
// If our data is invalid, make sure to catch it early in the development process.
let frameworkBundle = Bundle(for: type(of: self))
let defaultCountriesJSONPath = frameworkBundle.path(forResource: "SwiftCountryPicker.bundle/Data/countryCodes",
ofType: "json")!
let defaultCountriesJSONData = try! Data(contentsOf: URL(fileURLWithPath: defaultCountriesJSONPath))
let defaultCountriesDictionaries = try! JSONSerialization.jsonObject(with: defaultCountriesJSONData,
options: .allowFragments) as! NSArray
import Foundation
import CoreLocation
class Location: NSObject {
static let shared = Location()
private override init() {
super.init()
manager.delegate = self
typedef NS_ENUM(NSUInteger, Degrees) {
DegreesCelsius,
DegreesFahrenheit,
DegreesKelvin,
};
- (NSString *)highestTemperatureForecasted:(WAForecastModel *)forecast degrees:(Degrees)type;
{
WADayForecast *dailyForecast = forecast.dailyForecasts.firstObject;