This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension KeyedEncodingContainer { | |
mutating func encode(_ value: UIImage, | |
forKey key: KeyedEncodingContainer.Key) throws { | |
let imageData = value.jpegData(compressionQuality: 1) | |
let prefix = "data:image/jpeg;base64," | |
guard let base64String = imageData?.base64EncodedString(options: .lineLength64Characters) else { | |
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: "Can't encode image to base64 string.")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrderSummaryViewController: UIViewController { | |
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
if segue.identifier == "checkout" { | |
let vc = segue.destination as! DeliveryAddressViewController | |
vc.cart = cart // pass along cart information to next view controller | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OrderSummaryViewController: UIViewController { | |
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
if segue.identifier == "checkout" { | |
let vc = segue.destination as! ShippingOptionViewController | |
vc.cart = cart // pass along cart information to next view controller | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cart { | |
var items: [Product] | |
var paymentMethod: PaymentMethod | |
// Old implementation | |
var deliveryAddress: String | |
var shippingOption: ShippingOption | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
private var purchaseCoordinator: PurchaseCoordinator | |
func application(_ application: UIApplication, | |
didFinishLaunchingWithOptions launchOptions: | |
[UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
let window = UIWindow(frame: UIScreen.main.bounds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
protocol ProductListViewControllerDelegate: class { | |
func productListViewController(_ vc: ProductListViewController, didSelectProduct product: Product) | |
} | |
class ProductListViewController: UIViewController { | |
weak var delegate: ProductListViewControllerDelegate? | |
} | |
protocol ProductDetailViewControllerDelegate: class { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>StringsTable</key> | |
<string>Root</string> | |
<key>PreferenceSpecifiers</key> | |
<array> | |
<dict> | |
<key>Type</key> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>StringsTable</key> | |
<string>Child</string> | |
<key>PreferenceSpecifiers</key> | |
<array> | |
<dict> | |
<key>Type</key> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>StringsTable</key> | |
<string>Root</string> | |
<key>PreferenceSpecifiers</key> | |
<array> | |
<dict> | |
<key>Type</key> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$PROJECT_DIR/$INFOPLIST_FILE") | |
build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$PROJECT_DIR/$INFOPLIST_FILE") | |
/usr/libexec/PlistBuddy -c "Set PreferenceSpecifiers:0:DefaultValue $version ($build)" "$SRCROOT/FunWithSettings/Settings.bundle/Root.plist" |