Fill a plist with quotes - iphone

I have been doing some work for a while on an iPhone daily quote app, and the bulk of comments I received are to use a plist to store the quotes, and then setup the code to randomly access a quote each day. I have never really worked with a plist though, and am unsure as to the best way to build a new one filled with quotes. Could I get some guidance on this?

Your plist could look something like this.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>A Quote</string>
<string>A Quote</string>
<string>A Quote</string>
</array>
</plist>
You can open a plist into an array like this. You'd then have an array of strings that you could do whatever you want with. Once you have an array I assume you know how to get a random object from it.
[NSArray arrayWithContentsOfFile:#"myPlist.plist"];

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>files</key>
<dict>
<key>Resources/Info.plist</key>
<data>
OkWU6AfEeAr3G1LVjwgv3QVl/C4=
</data>
</dict>
<key>files2</key>
<dict>
<key>Resources/Info.plist</key>
<dict>
<key>hash</key>
<data>
OkWU6AfEeAr3G1LVjwgv3QVl/C4=
</data>
<key>hash2</key>
<data>
bTnXxa3Ed3AQ3vCPs76DvwtUwOlgsWxMGNleo3ICfKA=
</data>
</dict>
</dict>
<key>rules</key>
<dict>
<key>^Resources/</key>
<true/>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^.*</key>
<true/>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^[^/]+$</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>

Related

How to decode this nested dictionary .plist file with dynamic keys to swift class or struct in swift?

I have been searching all the internet to correctly parse the following plist in swift but I cannot manage to find the correct way to do it. Please help. I have tried with multiple structures and classes with no result, the data will not fill the structures as it should.
If I try to cast it from bundle as NSDictionary it works but if I try to iterate through all of its dictionaries from class1, class2, etc appear as one single value that I cannot iterate through or work with.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>class1</key>
<dict>
<key>RANDOM_NAME1</key>
<dict>
<key>path</key>
<array>
<string>test</string>
<string>test</string>
<string>test</string>
</array>
</dict>
<key>RANDOM_NAME2</key>
<dict>
<key>path</key>
<array>
<string>test</string>
<string>test</string>
<string>test</string>
<string>test</string>
<string>test</string>
</array>
</dict>
</dict>
<key>class2</key>
<dict>
<key>RANDOM_NAME1</key>
<dict>
<key>path</key>
<array>
<string>test</string>
<string>test</string>
<string>test</string>
</array>
</dict>
<key>RANDOM_NAME2</key>
<dict>
<key>path</key>
<array>
<string>test</string>
<string>test</string>
<string>test</string>
<string>test</string>
<string>test</string>
</array>
</dict>
</dict>
<key>class3</key>
<dict>
<key>RANDOM_NAME1</key>
<dict>
<key>path</key>
<array>
<string>test</string>
<string>test</string>
<string>test</string>
</array>
</dict>
<key>RANDOM_NAME2</key>
<dict>
<key>path</key>
<array>
<string>test</string>
<string>test</string>
<string>test</string>
<string>test</string>
<string>test</string>
</array>
</dict>
</dict>
</dict>
</plist>
Please note that RANDOM_NAME1, RANDOM_NAME2 etc are random keys that i do not know, and their number may vary.
You can read information from plist file using this code:
Bundle.main.object(forInfoDictionaryKey: RANDOM_NAME1);
Otherwise you want to receive all plist file as dictionary to work with him you can use this code:
Bundle.main.infoDictionary

Phonegap Facebook Login not returning to my iphone App

I am trying to integrate the FacebookSDK-3.1.1 into my IPhone app (using Phonegap 2.1.0). I can't get back to my app once logged in.
My aim is facebook share using IPhone App.
Below i provide my [PROJECTNAME]-Info.plist file and Cordova.plist file.
Any help would be very much appreciated.
Thanks
[PROJECTNAME]-Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>icon.png</string>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>icon.png</string>
<string>icon#2x.png</string>
<string>icon-72.png</string>
<string>icon-72#2x.png</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
<key>CFBundleIdentifier</key>
<string>com.Kwazzi.phonegap</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSMainNibFile</key>
<string></string>
<key>NSMainNibFile~ipad</key>
<string></string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>FacebookAppID</key>
<string>xxxxxxxxxxxxxxx</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbxxxxxxxxxxxxxxx</string>
</array>
</dict>
</array>
</dict>
</plist>
Cordova.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIWebViewBounce</key>
<true/>
<key>TopActivityIndicator</key>
<string>gray</string>
<key>EnableLocation</key>
<false/>
<key>EnableViewportScale</key>
<false/>
<key>AutoHideSplashScreen</key>
<true/>
<key>ShowSplashScreenSpinner</key>
<true/>
<key>MediaPlaybackRequiresUserAction</key>
<false/>
<key>AllowInlineMediaPlayback</key>
<false/>
<key>OpenAllWhitelistURLsInWebView</key>
<false/>
<key>BackupWebStorage</key>
<true/>
<key>ExternalHosts</key>
<array>
<string>*</string>
</array>
<key>Plugins</key>
<dict>
<key>org.apache.cordova.facebook.Connect</key>
<string>FacebookConnectPlugin</string>
<key>Device</key>
<string>CDVDevice</string>
<key>Logger</key>
<string>CDVLogger</string>
<key>Compass</key>
<string>CDVLocation</string>
<key>Accelerometer</key>
<string>CDVAccelerometer</string>
<key>Camera</key>
<string>CDVCamera</string>
<key>NetworkStatus</key>
<string>CDVConnection</string>
<key>Contacts</key>
<string>CDVContacts</string>
<key>Debug Console</key>
<string>CDVDebugConsole</string>
<key>Echo</key>
<string>CDVEcho</string>
<key>File</key>
<string>CDVFile</string>
<key>FileTransfer</key>
<string>CDVFileTransfer</string>
<key>Geolocation</key>
<string>CDVLocation</string>
<key>Notification</key>
<string>CDVNotification</string>
<key>Media</key>
<string>CDVSound</string>
<key>Capture</key>
<string>CDVCapture</string>
<key>SplashScreen</key>
<string>CDVSplashScreen</string>
<key>Battery</key>
<string>CDVBattery</string>
</dict>
</dict>
</plist>
You dont have the proper configuration in your [PROJECTNAME]-Info.plist. You miss "CFBundleURLName". Try the code below, it would help you.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.facebook.phonegap.myscheme</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fbxxxxxxxxxxxxxxx</string>
</array>
</dict>
</array>

ios : Changes in info.plist for opening file types like doc and pdf

I am a newbie to ios,there is a requirement in my app to support showing and opening up of file types like doc,pdf when requested in other app like dropbox. I read Apple's documentation and it says adding a row "Document types" in info.plist. But i am not sure what values i have to put in there if its for doc ,pdf.
I am not sure either if this is the right the approach i have to follow .
Add following dict to info plist for opening file types like doc and pdf
------------- For PDF ----------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>PDFIcon64.png</string>
<string>PDFIcon320.png</string>
</array>
<key>CFBundleTypeName</key>
<string>PDF</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSItemContentTypes</key>
<array>
<string>com.adobe.pdf</string>
</array>
</dict>
</plist>
------- For DOC -----------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>PDFIcon64.png</string>
<string>PDFIcon320.png</string>
</array>
<key>CFBundleTypeName</key>
<string>DOC</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSItemContentTypes</key>
<array>
<string>com.microsoft.word.doc</string>
<string>org.openxmlformats.wordprocessingml.document</string>
<string>org.openxmlformats.wordprocessingml.document.macroenabled</string>
</array>
</dict>
</plist>

Implement Emoticons in xcode

I am tryingt o build an application where I am giving user liberty to add the emojis as in GTalk (e.g. :P :) :( ...). But I am not able to figure out the exact way to handle and display them once the characters are entered by the user.
Kindly pour in ideas for the same, as any form of help could trigger a solution for this.
For inputs you can use custom buttons, setting their titles with the unicode representation of the emojis. Iphone has native support for this.
[myButton setTitle:#"\ue415" forState:UIControlStateNormal];
For display it in a textbox you have to handle this as a single char of a string so you can concatenate your regular text with emojis.
A complete list of emojis are listed in this page: http://pukupi.com/post/1964/
Edit: You can use a conversion table
:) = \ue415
:( = \ue40e
....
You can use that conversion table with using images instead unicode chars but it is very complicated if you want to merge text and images in the same paragraph.
Here is an example using a property list if you want to use images
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SparkSetVersion</key>
<integer>1</integer>
<key>Emoticons</key>
<dict>
<key>angry.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>>:o</string>
<string>>:-o</string>
<string>>:O</string>
<string>>:-O</string>
<string></string>
</array>
<key>Name</key>
<string>Angry</string>
</dict>
<key>blush.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-[</string>
</array>
<key>Name</key>
<string>Blush</string>
</dict>
<key>confused.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>?:|</string>
</array>
<key>Name</key>
<string>Confused</string>
</dict>
<key>cool.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>B-)</string>
</array>
<key>Name</key>
<string>Cool</string>
</dict>
<key>cry.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:'(</string>
<string></string>
</array>
<key>Name</key>
<string>Cry</string>
</dict>
<key>devil.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>]:)</string>
</array>
<key>Name</key>
<string>Devil</string>
</dict>
<key>grin.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-D</string>
<string>:D</string>
<string></string>
</array>
<key>Name</key>
<string>Grin</string>
</dict>
<key>happy.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-)</string>
</array>
<key>Name</key>
<string>Happy</string>
</dict>
<key>laugh.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:^0</string>
</array>
<key>Name</key>
<string>Laugh</string>
</dict>
<key>love.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:x</string>
</array>
<key>Name</key>
<string>Love</string>
</dict>
<key>mischief.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>;\</string>
</array>
<key>Name</key>
<string>Mischief</string>
</dict>
<key>mischief.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>;\</string>
</array>
<key>Name</key>
<string>Mischief</string>
</dict>
<key>sad.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-(</string>
<string>:(</string>
<string></string>
</array>
<key>Name</key>
<string>Sad</string>
</dict>
<key>smile.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-)</string>
<string>:)</string>
<string></string>
</array>
<key>Name</key>
<string>Smile</string>
</dict>
<key>silly.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>:-p</string>
<string>:-P</string>
<string>:P</string>
<string>:p</string>
<string></string>
</array>
<key>Name</key>
<string>Tongue</string>
</dict>
<key>cool.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>8-)</string>
<string></string>
</array>
<key>Name</key>
<string>Cool</string>
</dict>
<key>wink.png</key>
<dict>
<key>Equivalents</key>
<array>
<string>;-)</string>
<string>;)</string>
<string></string>
</array>
<key>Name</key>
<string>Wink</string>
</dict>
</dict>
</dict>
</plist>

root.plist changes not visible on iphone

when i add new entries to my settings bundle root.plist file, build and run the app, the new settings are not visible within the app. I've of course used a unique key for the new entries.
In my root.plist file in the xcode project the file shows the changes, but when i get the current file from the iphone via the organizer, the changes are not there.
I am using iOs 4.0.1.
BR,
Martin
Delete and reinstall the app. There's a bug where updated resources may not be installed when the app already exists on the device.
Root.pList
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>iParkschein Einstellungen</string>
</dict>
<dict>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Kennzeichen</string>
<key>Key</key>
<string>kennzeichen_preference</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
</dict>
<dict>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Stadt</string>
<key>Key</key>
<string>stadt_preference</string>
<key>DefaultValue</key>
<string>Wien</string>
<key>IsSecure</key>
<false/>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Firmenrechnung</string>
<key>Key</key>
<string>firmenrechnung_preference</string>
<key>DefaultValue</key>
<true/>
</dict>
<dict>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<key>Title</key>
<string>Kennzeichen</string>
<key>Key</key>
<string>servicenummer_preference</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
</dict>
</array>
</dict>
</plist>
if i read the keys from the userdefaults and write them to the console, i get ever key except the servicenummer_preference
BR,
Martin