-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e16ce13
commit 8e7e2b8
Showing
44 changed files
with
3,099 additions
and
0 deletions.
There are no files selected for viewing
459 changes: 459 additions & 0 deletions
459
263-cloudkit-references/CloudKitReferences/HelloCloudKit.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...cloudkit-references/CloudKitReferences/HelloCloudKit.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
263-cloudkit-references/CloudKitReferences/HelloCloudKit/AddressCell.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// AddressCell.swift | ||
// HelloCloudKit | ||
// | ||
// Created by Ben Scheirman on 3/29/17. | ||
// Copyright © 2017 NSScreencast. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class AddressCell : UITableViewCell { | ||
@IBOutlet weak var addressLabel: UILabel! | ||
} |
102 changes: 102 additions & 0 deletions
102
263-cloudkit-references/CloudKitReferences/HelloCloudKit/AppDelegate.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// | ||
// AppDelegate.swift | ||
// HelloCloudKit | ||
// | ||
// Created by Ben Scheirman on 1/30/17. | ||
// Copyright © 2017 NSScreencast. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import CoreLocation | ||
import CloudKit | ||
|
||
@UIApplicationMain | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
||
var window: UIWindow? | ||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | ||
|
||
|
||
setupAppearance() | ||
checkAccountStatus() | ||
|
||
|
||
NotificationCenter.default.addObserver(forName: .CKAccountChanged, | ||
object: nil, | ||
queue: nil) { [weak self] (note) in | ||
print("Identity changed.") | ||
self?.checkAccountStatus() | ||
} | ||
|
||
return true | ||
} | ||
|
||
func checkAccountStatus() { | ||
print("Checking account status:") | ||
let container = CKContainer.default() | ||
container.accountStatus { (accountStatus, error) in | ||
|
||
print("Account status: \(accountStatus.rawValue)") | ||
|
||
switch accountStatus { | ||
case .available: | ||
break | ||
|
||
case .noAccount: | ||
self.promptForICloud() | ||
|
||
case .couldNotDetermine: | ||
if let e = error { | ||
print("Error checking account status: \(e)") | ||
} | ||
|
||
case .restricted: | ||
print("restricted") | ||
} | ||
} | ||
} | ||
|
||
func promptForICloud() { | ||
print("Prompt for iCloud") | ||
|
||
let alert = UIAlertController(title: "iCloud Login Required", | ||
message: "This app uses iCloud to store data about restaurants. Please log in in the Settings app", | ||
preferredStyle: .alert) | ||
alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil)) | ||
window?.rootViewController?.present(alert, animated: true, completion: nil) | ||
} | ||
|
||
func applicationWillResignActive(_ application: UIApplication) { | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. | ||
} | ||
|
||
func applicationDidEnterBackground(_ application: UIApplication) { | ||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
} | ||
|
||
func applicationWillEnterForeground(_ application: UIApplication) { | ||
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. | ||
} | ||
|
||
func applicationDidBecomeActive(_ application: UIApplication) { | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
} | ||
|
||
func applicationWillTerminate(_ application: UIApplication) { | ||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
} | ||
|
||
|
||
private func setupAppearance() { | ||
window?.tintColor = #colorLiteral(red: 0.5226279145, green: 0.02596991433, blue: 0, alpha: 1) | ||
|
||
let navbar = UINavigationBar.appearance() | ||
navbar.titleTextAttributes = [ | ||
NSForegroundColorAttributeName: UIColor(red:0.46, green:0.38, blue:0.22, alpha:1.00) | ||
] | ||
} | ||
} | ||
|
48 changes: 48 additions & 0 deletions
48
...erences/CloudKitReferences/HelloCloudKit/Assets.xcassets/AppIcon.appiconset/Contents.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "20x20", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "20x20", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
263-cloudkit-references/CloudKitReferences/HelloCloudKit/Assets.xcassets/Contents.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...t-references/CloudKitReferences/HelloCloudKit/Assets.xcassets/user.imageset/Contents.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "user@2x.png", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+989 Bytes
...nces/CloudKitReferences/HelloCloudKit/Assets.xcassets/user.imageset/user@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions
27
263-cloudkit-references/CloudKitReferences/HelloCloudKit/Base.lproj/LaunchScreen.storyboard
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<scenes> | ||
<!--View Controller--> | ||
<scene sceneID="EHf-IW-A2E"> | ||
<objects> | ||
<viewController id="01J-lp-oVM" sceneMemberID="viewController"> | ||
<layoutGuides> | ||
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/> | ||
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/> | ||
</layoutGuides> | ||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | ||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> | ||
</view> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="53" y="375"/> | ||
</scene> | ||
</scenes> | ||
</document> |
Oops, something went wrong.