Skip to content

Commit

Permalink
Refactor String extension
Browse files Browse the repository at this point in the history
To add fileString method that it will be in charge of return the file as string.
  • Loading branch information
Rafael da Silva Ferreira committed Mar 30, 2017
1 parent eb27dfb commit 7df7e90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion JSONStub.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'JSONStub'
s.version = '0.1.3'
s.version = '0.1.4'
s.summary = 'Use JSONStub to easily load JSON files into your Mappable objects.'

# This description is used to generate tags and improve search results.
Expand Down
6 changes: 6 additions & 0 deletions JSONStub/Classes/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public extension String {
return json as? [String: AnyObject]
}

func fileString() -> String {
guard let data = fileData(), let json = String.init(data: data, encoding: .utf8) else { return "{}" }

return json
}

func filePath() -> String? {
guard splitAtDot.count == 2 else { return nil }

Expand Down

0 comments on commit 7df7e90

Please sign in to comment.