{"id":15293663,"url":"https://github.com/caiyue1993/prefsmate","last_synced_at":"2025-07-16T03:32:43.448Z","repository":{"id":56921472,"uuid":"104839095","full_name":"caiyue1993/PrefsMate","owner":"caiyue1993","description":"🐣  Elegant UITableView generator for Swift.","archived":false,"fork":false,"pushed_at":"2020-10-10T07:52:23.000Z","size":85,"stargazers_count":119,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T13:41:30.205Z","etag":null,"topics":["codable","ios","swift4","uitableview"],"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/caiyue1993.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}},"created_at":"2017-09-26T05:18:00.000Z","updated_at":"2023-08-01T22:29:39.000Z","dependencies_parsed_at":"2022-08-21T04:50:45.274Z","dependency_job_id":null,"html_url":"https://github.com/caiyue1993/PrefsMate","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiyue1993%2FPrefsMate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiyue1993%2FPrefsMate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiyue1993%2FPrefsMate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiyue1993%2FPrefsMate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caiyue1993","download_url":"https://codeload.github.com/caiyue1993/PrefsMate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248718834,"owners_count":21150642,"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":["codable","ios","swift4","uitableview"],"created_at":"2024-09-30T16:50:27.165Z","updated_at":"2025-04-13T13:23:53.369Z","avatar_url":"https://github.com/caiyue1993.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PrefsMate\n\n[![CI Status](http://img.shields.io/travis/caiyue1993/PrefsMate.svg?style=flat)](https://travis-ci.org/caiyue1993/PrefsMate)\n\u003ca href=\"https://swift.org/package-manager/\"\u003e\u003cimg src=\"https://img.shields.io/badge/SPM-supported-DE5C43.svg?style=flat\"\u003e\u003c/a\u003e\n[![Version](https://img.shields.io/cocoapods/v/PrefsMate.svg?style=flat)](http://cocoapods.org/pods/PrefsMate)\n[![License](https://img.shields.io/cocoapods/l/PrefsMate.svg?style=flat)](http://cocoapods.org/pods/PrefsMate)\n[![Platform](https://img.shields.io/cocoapods/p/PrefsMate.svg?style=flat)](http://cocoapods.org/pods/PrefsMate)\n\nPrefsMate provide an elegant way to generate UITableView using a property list file(plist file, in short). Also, you can configure actions with its support. Thanks to the **Codable** protocol, it makes the code perfect clean.\n\n## Features\n- [x] Data Persistence\n- [x] Switch Accessory\n- [x] Select Action\n- [x] Muilty Sections\n- [x] Section Header / Footer \n- [x] Demo Project\n- [x] World Ready\n- [ ] More Custom Cells\n\n## Background\n\nIn our app, we usually need a UITableView in PrefsViewController(or perhaps named SettingsViewController, whatever). And the interface may just looks like this:\n\n![PrefsViewController](https://i.loli.net/2017/10/20/59e9c804d4aa2.png)\n\nWhen implementing this kind of stuff, your inner voice must be this: \"Writing this UI is fxxking tedious! Is there any help that I can ask for?\" \n\nAnd congrats! You have come to the right place :).  \n\n## Usage\n\n## 1. Prepare a plist file containing formatted data \n\nTaking example of the image above, the formatted plist file looks like this:\n\n![plist structure](https://i.loli.net/2017/10/20/59e9c921e41aa.png)\n\nThe meaning of each item property is as follows:\n\n| Property      | usage         | \n| :-----------: | :-----------: |\n| `title`      | the text on the left | \n| `detailText`   | the text on the right   |  \n| `hasDisclosure` | whether the cell has a disclosure accessory view|\n| `hasSwitch` | whether the cell has a switch |\n| `switchStatus` | the status of the switch control |\n| `selectActionName` | the name of select action(optional) |\n| `switchActionName` | the name of switch action(optional)  | \n\n\u003e Don't be afraid of this long file. In fact you just need to do some clickable things. You could even copy and paste [our plist source code](https://github.com/caiyue1993/PrefsMate/blob/master/Example/PrefsMate/Prefs.plist) first just for your convenience.\n\n## 2. Create the table view and do the parsing job\n```swift\nlet tableView = Mate.createPrefsTableView()\n```\n\nYou can add the parsing code in viewDidLoad():\n```swift\n do {\n      try Mate.parseWithSource(self, plistUrl: pListUrl) {\n        tableView.reloadData()\n      }\n    } catch {\n        // Handle with the error\n    }\n```\n\n## 3. If needed, let your view controller conform to PrefsSupportable protocol\n\nIf you have select and switch action to handle, PrefsSupportable protocol already considered for you. \n\n```swift\npublic protocol PrefsSupportable {\n    /// Return a bunch of switchableItems, including their behavior in SwitchableItemHandler.\n    var switchableItems: [SwitchActionName: SwitchableItemHandler]? { get }\n    \n    /// Return a bunch of selectableItems, including their behavior in SelectableItemHandler.\n    var selectableItems: [SelectActionName: SelectableItemHandler]? { get }\n}\n```\n\nTaking the switch of night theme for example:\n\n```swift\nvar switchableItems: [SwitchActionName : SwitchableItemHandler]? {\n        return [\n            \"handleThemeMode\": { isOn in\n                print(\"Dark theme mode is \\(isOn)\")\n            }\n        ]\n}\nvar selectableItems: [SelectActionName : SelectableItemHandler]? {\n        return [\n            “changeIcon”: { \n                print(“Handle change icon action here”)\n            }\n           ...\n           ...\n        ]\n}\n```\n\nThen we are done! PrefsMate will do right things for you.\n\n\u003e Keep in mind: the \"handleThemeMode\" String must be the same value of `switchActionName` in the plist file. Same on `selectActionName`.\n\n\u003e In switch actions, PrefsMate already take care of the **data persistence**. So you don’t need to store the user preferences yourself.\n\nYou could refer to [Example project](https://github.com/caiyue1993/PrefsMate/tree/master/Example) for more detail.\n\n## Suggestions\n\n- Being familiar with plist file structure will help you a lot. Sometimes you can directly edit the plist file through \"Open As Source Code\". \n\n- If you have an issue, please don't hesitate. Just let me know :)\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory.\n\n(Cuz this is a new Pod, you may need to `pod update` first.)\n\n## Requirements\n\n- Swift 5\n- iOS 9 or later\n\n## Installation\n\nPrefsMate is available through Swift Package Manager \u0026 [CocoaPods](http://cocoapods.org). \n\n### Swift Package Manager\nFrom Xcode 11, you can use Swift Package Manager to add Kingfisher to your project.\n\n1. Select File \u003e Swift Packages \u003e Add Package Dependency. Enter https://github.com/caiyue1993/PrefsMate.git in the \"Choose Package Repository\" dialog.\n2. In the next page, specify the version resolving rule as \"Up to Next Major\" with latest release version\n3. After Xcode checking out the source and resolving the version, you can choose the \"PrefsMate\" library and add it to your app target.\n\nIf you encounter any problem or have a question on adding package to an Xcode project, I suggest the [Adding Package Dependencies to Your App guide](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) article from Apple.\n\n### CocoaPods\nTo install it, simply add the following line to your Podfile:\n\n```ruby\npod 'PrefsMate'\n```\n\n## Contact\n\n- Weibo: [@CaiYue_](http://weibo.com/caiyue233)\n- Twitter: [@caiyue5](https://twitter.com/caiyue5)\n\n## License\n\nPrefsMate is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaiyue1993%2Fprefsmate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaiyue1993%2Fprefsmate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaiyue1993%2Fprefsmate/lists"}