plist in Index.html using phonegap - ios

Can I read a plist file in my index.HTML? Actually I want to add multiple links with which application will interact, and I want those links to be in a plist. Is there any way to retrieve them in HTML file?
please help
thanks

Well, if the file is in the www folder, you could parse it using an XML parser, or even a specialty plist parser such as this: https://github.com/pugetive/plist_parser
If you are looking to have the file outside the www folder you might also need to use PhoneGap's File API to get the contents of the file.

Related

Updating plist file via code

I have created a plist file in the bundle, and I'm trying update the user's information into the plist. I know that I should copy the plist file from the bundle to the document directory, and edit it from there, but I still have a couple questions:
When I copy the plist file to the document directory, is it permanent? I mean, if I close the program and open it again, I can simply edit the plist file in the document directory, right?
If so, does it mean that I should only execute the code that copies the plist file to the document directory once the app is launched for the first time?
/main question/ Since I want a blank plist file for the user to update their data with, should I just simply create a plist file on the first launch? It'll be a lot easier without the copying around bundles and stuff.
I mean, what is the point of creating a plist file in the bundle in the first place? We will copying it into the document directory anyway, so why not just create one in code?
Yes. Writing a file is permanent, as long as you obviously don't delete/move the file somewhere else.
That is a valid option
Yes. If you need a blank file, you don't need it from the bundle. A better idea would be to create it when you need it (when there is something to write). Usually file creations are managed like so
Check if file exists
If not, create it.
Use the file.
If you need a template file (with already some stuff written in it), then a copy from the bundle is more appropriate. But even then, a lot of developers will like to do everything from code, it's not that heavy of a task, and it forces you to create/prepare the right objects and methods from the get-go.
Like Rooe N said, the NSUserDefaults IS a property list, so if you're talking about very simple data, say, like a username and a last-time-I-logged-In-date, you could store it there.
Note that NSUserDefaults are loaded all the way, every time you load the app, so you don't wanna use it as a database. But since you're going for .plist, I'll assume you've already ruled DBs out.
I'm not completely sure what you are trying to achieve, but you should think of plist as a place for global Constants not something that should be updated on runtime.
Maybe you should look at this:
NSUserDefaults

Generate JSON file from Xcdatamodel

Is it possible to generate JSON file from xcdatamodel?
Here's how I imagine it would work: Given a xcdatamodel file, going through some program with some custom logic (will probably be written by me), will generate JSON file for me to use in third-party library. My question: Is this possible? Has anyone ever done it?
The content of xcdatamodel is a content file with xml data and as bin file (no extension) so now it is easy to parse xml to json.

Custom filepath on server parse.com

I'm working with parse.com for my server end. I'm wondering if there's a way for files to be saved into subfolders. For example my file is currently saved with a url like this:
http://files.parsetfss.com/bb2767e6-fc18-4ff5-a071-199803c9aac2/tfss-d056e28e-1e02-49dd-930b-e46790a2e38d-Drums.png
is there a way I can get it to look like this instead:
http://files.parsetfss.com/bb2767e6-fc18-4ff5-a071-199803c9aac2/tfss-d056e28e-1e02-49dd-930b-e46790a2e38d/Drums.png
and for the same extension (tfss-d056e28e-1e02-49dd-930b-e46790a2e38d) apply to each row?
The reason I need this is because I'm actually uploading html files and it can't find its assets if they get renamed...
Have a look at the Cloud Hosting documentation here:
https://parse.com/docs/hosting_guide
Basically whatever files/folders you put in the "public" folder will be publicly available.
You can use it to upload files you want to be shared normally, instead of the way you described in your question which is for files you want to attach to objects.

iOS Enterprise OTA - Is there a way to output plist from php?

I want to use php to output plist that is in item-service link.
Like this
itms-services://?action=download-manifest&url=xxxxxx.php?id=xxx
(In php file, output plist string from app data in db)
Is it possible?
If it is possible, please show me example code in php file.
A plist file is just a specially formed XML file. This is something you could generate in any language. Examples for PHP XML output can be found in other questions such as this one: How to output XML string from PHP

Where to store XML files in Rails

I am writing a Ruby on Rails site which loads some data from an "local" XML file which I have. Where is a logical place in the rails directory structure to store this file?
Main question here is for what reason you have that XML files: configuration info or data storage. If first - then best place will be congif folder, otherwise - anywhere you like except public folder, you could even create xml folder inside app one.

Resources