Skip to content

Commit 7df7e90

Browse files
author
Rafael da Silva Ferreira
committed
Refactor String extension
To add fileString method that it will be in charge of return the file as string.
1 parent eb27dfb commit 7df7e90

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

JSONStub.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'JSONStub'
11-
s.version = '0.1.3'
11+
s.version = '0.1.4'
1212
s.summary = 'Use JSONStub to easily load JSON files into your Mappable objects.'
1313

1414
# This description is used to generate tags and improve search results.

JSONStub/Classes/String.swift

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ public extension String {
2222
return json as? [String: AnyObject]
2323
}
2424

25+
func fileString() -> String {
26+
guard let data = fileData(), let json = String.init(data: data, encoding: .utf8) else { return "{}" }
27+
28+
return json
29+
}
30+
2531
func filePath() -> String? {
2632
guard splitAtDot.count == 2 else { return nil }
2733

0 commit comments

Comments
 (0)