https://github.com/bodacious/plistreadwrite
A Rubymotion module to make light work of writing to and reading from plist files.
https://github.com/bodacious/plistreadwrite
Last synced: 11 months ago
JSON representation
A Rubymotion module to make light work of writing to and reading from plist files.
- Host: GitHub
- URL: https://github.com/bodacious/plistreadwrite
- Owner: Bodacious
- License: mit
- Created: 2012-11-30T18:17:30.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2017-01-27T20:44:35.000Z (over 9 years ago)
- Last Synced: 2025-04-29T23:34:45.014Z (about 1 year ago)
- Language: Ruby
- Size: 139 KB
- Stars: 6
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# PListReadWrite
A Rubymotion module to make light work of writing to and reading from plist files.
## Installation
Add the following to your app's Gemfile
gem 'plist_read_write'
Alternatively, it's a small file so you can just copy/paste it directly to your app.
## Example Usage
Lets assume we have this plist file in our resources directory...
``` xml
jim
name
Jim
email
jim@jimsemail.com
jane
name
Jane
email
jane@janesemail.com
```
... and we want to copy it over to our app's documents directory so we can update/edit the plist.
``` ruby
# Check if the plist exists in our documents dir
PListRW.exist?(:users, :documentsDir) # => false
# Check if the plist exists in our main bundle
PListRW.exist?(:users, :mainBundle) # => true
# Copy the plist file from the main bundle to the documents dir
PListRW.copyPlistFileFromBundle(:users)
# Fetch the object from the plist file
@users_hash = PListRW.plistObject(:users, Hash) # => A hash containing the User data
# Update the data
@users_hash[:jim] # => { name: "Jim", email: "jim@jimsemail.com" }
@users_hash[:jim][:name] = 'James'
# Store the data back in the plist
PListRW.updatePlistFileWithObject(:users, @users_hash)
# Check this worked OK
PListRW.plistObject(:users, Hash)[:jim][:name] # => "James"
```
## About Katana Code
Katana Code are [iPhone app and Ruby on Rails Developers in Edinburgh, Scotland](http://katanacode.com/ "Katana Code").