{"id":21437615,"url":"https://github.com/gabrieltheodoropoulos/gtstorable","last_synced_at":"2026-05-19T00:36:38.099Z","repository":{"id":79559055,"uuid":"190147205","full_name":"gabrieltheodoropoulos/GTStorable","owner":"gabrieltheodoropoulos","description":"A Swift protocol which provides standard file operations for types conforming to Codable protocol.","archived":false,"fork":false,"pushed_at":"2019-06-04T08:24:17.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T09:43:37.550Z","etag":null,"topics":["archive","codable","documents","file","ios","json","plist","protocol","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gabrieltheodoropoulos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-04T06:59:45.000Z","updated_at":"2020-09-14T06:46:49.000Z","dependencies_parsed_at":"2023-03-13T07:30:24.231Z","dependency_job_id":null,"html_url":"https://github.com/gabrieltheodoropoulos/GTStorable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieltheodoropoulos%2FGTStorable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieltheodoropoulos%2FGTStorable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieltheodoropoulos%2FGTStorable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieltheodoropoulos%2FGTStorable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gabrieltheodoropoulos","download_url":"https://codeload.github.com/gabrieltheodoropoulos/GTStorable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243950792,"owners_count":20373664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["archive","codable","documents","file","ios","json","plist","protocol","swift"],"created_at":"2024-11-23T00:27:54.120Z","updated_at":"2026-05-19T00:36:38.068Z","avatar_url":"https://github.com/gabrieltheodoropoulos.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GTStorable\nA protocol which provides standard file operations for types conforming to Codable protocol.\n\n## Overview\n\n`GTStorable` protocol provides the following operations:\n\n* Saving to file.\n* Loading from file.\n* Removing data file.\n* Checking for data file existence.\n* Creating data file backup.\n* Removing data file backup.\n\n### Available API\n\n* `save(as:usingOptions:customCoders:)`\n* `load(from:forObjectOfType:usingOptions:customCoders:)`\n* `remove(fileOfType:usingOptions:)`\n* `dataFileExists(ofType:withOptions:)`\n* `backupDataFile(ofType:usingOptions:)`\n* `removeBackupFile(ofType:usingOptions:)`\n\nData can be encoded and saved to files in three formats currently: *JSON, Property List (plist) and Archived data*.\n\nRead the [documentation](https://gtiapps.com/docs/gtstorable/index.html) for more information about the protocol's methods and the custom types used and supported. Alternatively see documentation on the code files under the Source directory.\n\n## Integration\n\nYou can use **CocoaPods** for adding GTStorable to your workspace. In your Podfile include this:\n\n```ruby\npod 'GTStorable', :git =\u003e 'https://github.com/gabrieltheodoropoulos/GTStorable.git'\n```\n\n*Git URL is necessary as the pod is not pushed to the public trunk yet.*\n\nDo not forget to *import* GTStorable whenever necessary:\n\n```swift\nimport GTStorable\n```\n\nYou can also add GTStorable **manually** to your project. Download or clone the repository and drag-and-drop the Source directory into the Project Navigator in Xcode.\n\n## Usage Example\n\nConsider the following struct which conforms to GTStorable protocol.\n\n```swift\nstruct User: Codable, GTStorable {\n    var username: String?\n    var firstname: String?\n    var age: Int?\n    var isMale: Bool = true\n}\n```\n\nSaving an instance of it to file as a JSON can be done like this:\n\n```swift\ndo {\n    _ = try user.save(as: .json, usingOptions: nil, customCoders: nil)\n} catch { ... }\n\n// The user.json file will be created.\n\n```\n\nLoading:\n\n```swift\ndo {\n    let loadedUser = try User.load(from: .json, forObjectOfType: User.self, usingOptions: nil, customCoders: nil)\n} catch { ... }\n```\n\nYou can even create a backup of the data file:\n\n```swift\ndo {\n    _ = try user.backupDataFile(ofType: .json, usingOptions: nil)\n} catch { ... }\n\n// user.json.bak is the backup file created.\n\n```\n\nUse the `storeOptions` parameter to specify subdirectories, custom file names and extensions, even to change the working folder. By default, all files are stored to Documents directory of the app.\n\nAlso, provide optionally customized JSON and Property List encoder and decoder instances in the `customCoders` parameter (wherever applicable) for overriding the default used settings. See the documentation for more information.\n\n## Other\n\nCreated by [Gabriel Theodoropoulos](https://gtiapps.com). GTStorable is provided under MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrieltheodoropoulos%2Fgtstorable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabrieltheodoropoulos%2Fgtstorable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrieltheodoropoulos%2Fgtstorable/lists"}