I am using a Java library for parsing plist files.
This is how you parse a file:
File file = new File("Info.plist");
NSDictionary rootDict = (NSDictionary)PropertyListParser.parse(file);
As you can see, the parse
method returns an NSObject
object, which you cast to NSDictionary
or NSArray
depending on what you're working with.
But what if I don't know whether the root is a dictionary or an array? Given an NSObject
instance, how can I tell what does it represent?
Use instanceof
operator.
if (myObject instanceof NSArray) {
//do something
} else if (myObject instanceof NSDictionary) {
//do another thing
} else {
// (myObject instanceof NSObject) another subclass of NSObject
}