Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin work on version 4.0 API changes #133

Merged
merged 14 commits into from
Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,6 @@ for elem in xml["root"]["catalog"]["book"].all {
}
```

Alternatively, XMLIndexer provides `for-in` support directly from the index (no `all` needed in this case).

```swift
for elem in xml["root"]["catalog"]["book"] {
print(elem["genre"].element!.text!)
}
```

### Returning All Child Elements At Current Level

Given:
Expand Down Expand Up @@ -280,9 +272,9 @@ __Or__ using the existing indexing functionality:

```swift
switch xml["root"]["what"]["header"]["foo"] {
case .Element(let elem):
case .element(let elem):
// everything is good, code away!
case .XMLError(let error):
case .xmlError(let error):
// error is an IndexingError instance that you can deal with
}
```
Expand Down Expand Up @@ -404,15 +396,15 @@ See below for the code snippet to get this to work and note in particular the `p
extension NSDate: XMLElementDeserializable {
public static func deserialize(_ element: XMLElement) throws -> Self {
guard let dateAsString = element.text else {
throw XMLDeserializationError.NodeHasNoValue
throw XMLDeserializationError.nodeHasNoValue
}

let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss zzz"
let date = dateFormatter.dateFromString(dateAsString)

guard let validDate = date else {
throw XMLDeserializationError.TypeConversionFailed(type: "Date", element: element)
throw XMLDeserializationError.typeConversionFailed(type: "Date", element: element)
}

// NOTE THIS
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ end
desc 'Clean, build and test SWXMLHash'
task :test do |_t|
# xctool_build_cmd = './scripts/build.sh'
xcode_build_cmd = 'xcodebuild -workspace SWXMLHash.xcworkspace -scheme "SWXMLHash iOS" -destination "OS=10.2,name=iPhone 6S" clean build test -sdk iphonesimulator | xcpretty'
xcode_build_cmd = 'xcodebuild -workspace SWXMLHash.xcworkspace -scheme "SWXMLHash iOS" -destination "OS=10.3,name=iPhone 6S" clean build test -sdk iphonesimulator | xcpretty'

#if system('which xctool')
#run xctool_build_cmd
Expand Down
2 changes: 1 addition & 1 deletion Scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -ev

#xctool -scheme "SWXMLHash iOS" clean build test -sdk iphonesimulator
set -o pipefail && xcodebuild -workspace SWXMLHash.xcworkspace -scheme "SWXMLHash iOS" -destination "OS=10.0,name=iPhone 6S" clean build test -sdk iphonesimulator | xcpretty
set -o pipefail && xcodebuild -workspace SWXMLHash.xcworkspace -scheme "SWXMLHash iOS" -destination "OS=10.3,name=iPhone 6S" clean build test -sdk iphonesimulator | xcpretty
Loading