-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from insidegui/enum-support
Add support for encoding/decoding String and Int enum properties
- Loading branch information
Showing
7 changed files
with
120 additions
and
9 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
37 changes: 37 additions & 0 deletions
37
Tests/CloudKitCodableTests/TestTypes/TestModelWithEnum.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,37 @@ | ||
import Foundation | ||
import CloudKitCodable | ||
|
||
struct TestModelWithEnum: CustomCloudKitCodable, Hashable { | ||
enum MyStringEnum: String, CloudKitStringEnum, CaseIterable { | ||
case enumCase0 | ||
case enumCase1 | ||
case enumCase2 | ||
case enumCase3 | ||
} | ||
enum MyIntEnum: Int, CloudKitIntEnum, CaseIterable { | ||
case enumCase0 | ||
case enumCase1 | ||
case enumCase2 | ||
case enumCase3 | ||
} | ||
var cloudKitSystemFields: Data? | ||
var enumProperty: MyStringEnum | ||
var optionalEnumProperty: MyStringEnum? | ||
var intEnumProperty: MyIntEnum | ||
var optionalIntEnumProperty: MyIntEnum? | ||
} | ||
|
||
extension TestModelWithEnum { | ||
static let allEnumsPopulated = TestModelWithEnum( | ||
enumProperty: .enumCase3, | ||
optionalEnumProperty: .enumCase2, | ||
intEnumProperty: .enumCase1, | ||
optionalIntEnumProperty: .enumCase2 | ||
) | ||
static let optionalEnumNil = TestModelWithEnum( | ||
enumProperty: .enumCase3, | ||
optionalEnumProperty: nil, | ||
intEnumProperty: .enumCase1, | ||
optionalIntEnumProperty: nil | ||
) | ||
} |