Skip to content

Commit 551910d

Browse files
committed
adds Examples target and fix bugs
1 parent 8c63146 commit 551910d

File tree

22 files changed

+947
-24
lines changed

22 files changed

+947
-24
lines changed

.gitignore

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
2+
# Created by https://www.gitignore.io/api/swift,carthage,cocoapods
3+
# Edit at https://www.gitignore.io/?templates=swift,carthage,cocoapods
4+
5+
### Carthage ###
6+
# Carthage
7+
#
8+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
9+
# Carthage/Checkouts
10+
11+
Carthage/Build
12+
13+
### CocoaPods ###
14+
## CocoaPods GitIgnore Template
15+
16+
# CocoaPods - Only use to conserve bandwidth / Save time on Pushing
17+
# - Also handy if you have a large number of dependant pods
18+
# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE
19+
Pods/
20+
21+
### Swift ###
22+
# Xcode
23+
#
24+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
25+
26+
## Build generated
27+
build/
28+
DerivedData/
29+
30+
## Various settings
31+
*.pbxuser
32+
!default.pbxuser
33+
*.mode1v3
34+
!default.mode1v3
35+
*.mode2v3
36+
!default.mode2v3
37+
*.perspectivev3
38+
!default.perspectivev3
39+
xcuserdata/
40+
41+
## Other
42+
*.moved-aside
43+
*.xccheckout
44+
*.xcscmblueprint
45+
46+
## Obj-C/Swift specific
47+
*.hmap
48+
*.ipa
49+
*.dSYM.zip
50+
*.dSYM
51+
52+
## Playgrounds
53+
timeline.xctimeline
54+
playground.xcworkspace
55+
56+
# Swift Package Manager
57+
#
58+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
59+
# Packages/
60+
# Package.pins
61+
# Package.resolved
62+
.build/
63+
64+
# CocoaPods
65+
#
66+
# We recommend against adding the Pods directory to your .gitignore. However
67+
# you should judge for yourself, the pros and cons are mentioned at:
68+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
69+
#
70+
# Pods/
71+
#
72+
# Add this line if you want to avoid checking in source code from the Xcode workspace
73+
# *.xcworkspace
74+
75+
# Carthage
76+
#
77+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
78+
# Carthage/Checkouts
79+
80+
81+
# fastlane
82+
#
83+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
84+
# screenshots whenever they are needed.
85+
# For more information about the recommended setup visit:
86+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
87+
88+
fastlane/report.xml
89+
fastlane/Preview.html
90+
fastlane/screenshots/**/*.png
91+
fastlane/test_output
92+
93+
# Code Injection
94+
#
95+
# After new code Injection tools there's a generated folder /iOSInjectionProject
96+
# https://github.com/johnno1962/injectionforxcode
97+
98+
iOSInjectionProject/
99+
100+
# End of https://www.gitignore.io/api/swift,carthage,cocoapods
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// AppDelegate.swift
3+
// NestedCKCodableExamples
4+
//
5+
// Created by Guilherme Girotto on 22/11/18.
6+
// Copyright © 2018 Guilherme Girotto. All rights reserved.
7+
//
8+
9+
import NestedCloudKitCodable
10+
import UIKit
11+
12+
@UIApplicationMain
13+
class AppDelegate: UIResponder, UIApplicationDelegate {
14+
15+
var window: UIWindow?
16+
17+
18+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
19+
// Override point for customization after application launch.
20+
return true
21+
}
22+
23+
func applicationWillResignActive(_ application: UIApplication) {
24+
// 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.
25+
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
26+
}
27+
28+
func applicationDidEnterBackground(_ application: UIApplication) {
29+
// 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.
30+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31+
}
32+
33+
func applicationWillEnterForeground(_ application: UIApplication) {
34+
// 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.
35+
}
36+
37+
func applicationDidBecomeActive(_ application: UIApplication) {
38+
// 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.
39+
}
40+
41+
func applicationWillTerminate(_ application: UIApplication) {
42+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43+
}
44+
45+
46+
}
47+
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"size" : "29x29",
16+
"scale" : "2x"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"size" : "29x29",
21+
"scale" : "3x"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"size" : "40x40",
26+
"scale" : "2x"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"size" : "40x40",
31+
"scale" : "3x"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"size" : "60x60",
36+
"scale" : "2x"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"size" : "60x60",
41+
"scale" : "3x"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"size" : "20x20",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"size" : "20x20",
51+
"scale" : "2x"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"size" : "29x29",
56+
"scale" : "1x"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"size" : "29x29",
61+
"scale" : "2x"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"size" : "40x40",
66+
"scale" : "1x"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"size" : "40x40",
71+
"scale" : "2x"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"size" : "76x76",
76+
"scale" : "1x"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"size" : "76x76",
81+
"scale" : "2x"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"size" : "83.5x83.5",
86+
"scale" : "2x"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"size" : "1024x1024",
91+
"scale" : "1x"
92+
}
93+
],
94+
"info" : {
95+
"version" : 1,
96+
"author" : "xcode"
97+
}
98+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "default-user.png",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"version" : 1,
19+
"author" : "xcode"
20+
}
21+
}
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21+
</objects>
22+
<point key="canvasLocation" x="53" y="375"/>
23+
</scene>
24+
</scenes>
25+
</document>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="tne-QT-ifu">
11+
<objects>
12+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
21+
</objects>
22+
</scene>
23+
</scenes>
24+
</document>

NestedCloudKitCodable/Example Objects/Book.swift renamed to NestedCKCodableExamples/Example Objects/Book.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import Foundation
10+
import NestedCloudKitCodable
1011

1112
struct Book: CKCodable {
1213

NestedCloudKitCodable/Example Objects/Person.swift renamed to NestedCKCodableExamples/Example Objects/Person.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import UIKit
1010
import Foundation
11+
import NestedCloudKitCodable
1112

1213
struct Person: CKCodable {
1314

@@ -16,18 +17,16 @@ struct Person: CKCodable {
1617
}
1718

1819
var cloudKitIdentifier: String {
19-
return identifier
20+
return id
2021
}
2122

2223
var id = UUID().uuidString
2324
var picture: UIImage
24-
var identifier: String
2525
var name: String
2626
var birthDate: Date
2727

2828
init(name: String, birthDate: Date) {
29-
self.picture = UIImage(named: "userImage")!
30-
self.identifier = UUID().uuidString
29+
self.picture = UIImage(named: "default-user")!
3130
self.name = name
3231
self.birthDate = birthDate
3332
}
@@ -42,7 +41,7 @@ struct Person: CKCodable {
4241
let dataPicture = try container.decode(Data.self, forKey: .picture)
4342
self.picture = UIImage(data: dataPicture)!
4443

45-
self.identifier = try container.decode(String.self, forKey: .identifier)
44+
self.id = try container.decode(String.self, forKey: .identifier)
4645
self.name = try container.decode(String.self, forKey: .name)
4746
self.birthDate = try container.decode(Date.self, forKey: .birthDate)
4847
}
@@ -52,7 +51,7 @@ struct Person: CKCodable {
5251

5352
let pictureDate = picture.pngData()!
5453
try container.encode(pictureDate, forKey: .picture)
55-
try container.encode(identifier, forKey: .identifier)
54+
try container.encode(id, forKey: .identifier)
5655
try container.encode(name, forKey: .name)
5756
try container.encode(birthDate, forKey: .birthDate)
5857
}

0 commit comments

Comments
 (0)