is it possible to play movies out of a property list? Like is there's a "tag" with the filename in it which gets replaced by the actual iphone/ipad player? The movies are h.265 codec...
thanks
I'm assuming that you mean, can you use the property list as an array which will hold a bunch of filenames for movies that you want to play?
All the property list can be is a text file of sorts that contains a bunch of key-value pairs. I think you are misunderstanding what a property list file is.
Think about it this way: the info.plist file stores text data about your app when it runs or gets added to the AppStore. That's all it does though: stores text data. There are no special tricks like you're speaking of to get it to launch movies or anything else. You'd have to implement all of that in code yourself based on what the plist value was for a particular key.
Related
I'm trying to implement a autocomplete function into a small app. I want to give the user the possibility to write down a city (from a long long list of cities) into a NSComboBox. That works fine, as long as the user is using the exact writing of the city inside my array of city names. But if they use, for whatever reason, a different spelling, it fails and the city is not found.
So if the user is looking for "Köln" for example, it's not a problem, but if he is looking for "Cologne" he wouldn't be able to find it.
For this I have, for each city an additional array of alternative spellings.
Now I would love NSComboBox (or any other type of TextField) to look not only in "city.name" but also within the array "city.alternativeNames". The shown value should as well represent what the user is writing.
I don't want to create an entry in the list of the pop-up part of NSComboBox for each alternative name, as that would make the list even longer than it is and would confuse people (cologne alone has 85 different spellings).
Thanks for your suggestions, I'm completely new to NSComboBox.
Interesting problem. I think probably you need to choose a different way to structure your data to make it easier.
Consider the lookup method (matching a string). Structuring your data for this case should account for the preferred spelling of each city (preferred by you, for the scrolled list).
How about a flat array of cities (to allow a simple search based on user spelling without also having to check each possible array of alternates and manage sorting them properly) but each has an optional (can be nil) "preferred spelling" pointer to the "correct" one. When displaying the options in the combo box, show the array filtered by those with no optional preferred spellings plus the currently-typed partial/full completion of the alternate spelling?
So a City has a name property and an optional preferred property. In your case, if Cologne is preferred, the Köln instance would have Cologne set as preferred. Köln would only appear in the list if the user typed it (even partially) and it would automatically be in the correct alpha-sorted position (assuming your cities are kept sorted).
Does this make sense or do I need to rephrase? Haven't had enough coffee this morning. :-)
I have an object of type CGPDFDictionaryRef returned somehow from a method that is considered as a part of a static library (so I do not have access to its code to modify it), however, I want to know the name of the PDF file that this dictionary object holds ? how can I query it to get the name of the file?
There are two functions that take a CGPDFDocumentRef and return a CGPDFDictionaryRef. They are CGPDFDocumentGetInfo and CGPDFDocumentGetCatalog. Neither function returns a dictionary that contains the name of the original file. Neither does the array returned by CGPDFDocumentGetID.
This makes sense, because you can create a CGPDFDocumentRef without a file, from data you get over a socket or by drawing into a CGPDFContext with Quartz 2D.
If you want the name of the file, you'll have to get it some other way.
The CGPDF* functions are a function-based mechanism to get to the series of arrays, dictionaries, integers, string and name elements in PDF documents. PDF documents themselves are really just composed of these "basic" elements. If you'd like some light reading check out the ~1500 page PDF specification sometime. As rob mayoff stated, you are basically pointing to memory once you have a CGPDFDocumentRef.
That being said, there is no value that is guaranteed within a PDF structure that will give you the filename. Download Voyeur and dig around your PDF to look around and prove me wrong (I could be).
Here's the sample of the true contents of a PDF:
This may seem like a stupid question. But I have a plist for different categories in a iPhone application.
categories.plist
<key>cat1</key>
<string>Players</string>
...
Is it possible to localize this strings? This categories are created in to Core Data when the app is started for the first time. And if the user changes language after first launch the category names will still be in the language as when the application was first launched.
Is it possible in some way to localize the strings in the plist?
You can easily localize the entire file. Just select the file in Xocde and click the + button in the Localization section of the File Inspector to add multiple languages. You can then translate the file for each language.
If you just want to translate the strings, I would put keys into the plist file and translate those keys via the normal Localizable.strings file. In your code, you would then not use the strings directly but translate them first with NSLocalizedString().
you would typically create a plist file for each localization (not individual keys).
since that would duplicate the categories in each localization and in many cases only the translations change (not necessarily other keys), you could work around this if you use a separate lookup table (plist) for the localized translations of the values in the category plist. then you would use the category plist keyed values as keys for another localized lookup table (which would need only strings).
In my application, I have a tag multiple times. I'm using xml parser. I'm taking a corresponding element with similar name as the one in xml file in my class. So in case of:
<photo>abc</photo>
<photo>def</photo>
What I get in photo element of my class is the second element i.e def, as the first one gets overwritten as there's only one photo element in my class. My question is am I wrong in taking similar elements in class as in case of xml? Is there any better method or a better parser? Or I'm on right path and have to do this manually by setting some flags etc?
Thanx in advance.
I assume you try to parse the contents of an XML to match to properties on an object using NSXMLParser.
If it is valid to encounter multiple photo tags in your XML then either you need a strategy to know which one will map to a property, or convert your property to an NSArray and add the results as they come.
If it is not a valid case, you could check if you set the property earlier and raise an error, or just override it (as you do) and call it "undefined behavior".
There are many parsers there that can handle your issue (e.g. XPathQuery, TouchXML etc.).
I don't think that there is a need to reinvent the wheel - use one of the existing parsers.
In my application, I am using a plist. Please, can anyone explain what are the uses of plist with an example or a sample code?
In the context of iPhone development, Property Lists are a key-value store that your application can use to save and retrieve persistent data.
All iPhone applications have at least one of these by default, the Information Property List:
The information property list is a
file named Info.plist that is included
with every iPhone application project
created by Xcode. It is a property
list whose key-value pairs specify
essential runtime-configuration
information for the application. The
elements of the information property
list are organized in a hierarchy in
which each node is an entity such as
an array, dictionary, string, or other
scalar type.
Plist are XML files in a specific format. Prior to XML, they had a custom format now called 'old plist'. (You almost never see that anymore save in legacy code.)
Foundations collection classes automatically generate XML files in the plist format when you use their serialization methods to write them to disk. They also automatically read them back. You can also write your own serializers for your own custom objects. This allows you to persistently store complex objects in a robust, human readable format.
One use for plist for programmers is that it is easier to use the plist editor to input and manage a lot of data than it is to try and code it. For example, if you have an class that requires setting a large number of ivars, you can create a plist, read it into an NSArray or NSDictionary and then initialize the instance by passing it the dictionary.
I use this technique when I have to use a large number of paths to draw complex objects. You define the path in the plist file instead of the code and edit the path in the plist editor.
It's also a handy way to create a large amount of detailed test data.
PList means PropertyList
It is XML file format
It is mainly user for store and reterve the data
It can store the key-value pair
It's been a long time since I've looked at them, but plist is a short-form of "properties list" and can be used to store application configuration settings that need to persist between instances of an application's execution. Could be similar to a .properties file (I see those a lot on Java projects).
A plist is essentially just a data file, it stores information in a documented format.
From Wikipedia:
In the Mac OS X Cocoa, NeXTSTEP, and
GNUstep programming frameworks,
property list files are files that
store serialized objects. Property
list files use the filename extension
.plist, and thus are often referred to
as plist files. Property list files
are often used to store a user's
settings. They are also used to store
information about bundles and
applications, a task served by the
resource fork in the old Mac OS.
.plist
Info.plist is key/value persistence storage(property list) which is used by system and user. It contains user-friendly text in XML format. Info.plist is mandatory file for any Bundle. For example it contains Bundle id[About] which is usually is used by system but as a programmer/user you are not limited on changing/reading[More]. The same as you can add K/V for your own purposes and read it in runtime. You could noticed that some frameworks forces you to add K/V into your's application to identify you or some other cases.
.entitlements is a property list with enabled capabilities(e.g. ApplePay)
[Info.plist location]
[Vocabulary]