I have two questions. The first question is regarding the dictionary datatype that is used in a plist.
I have a few class methods that return specific floating point numbers. Rather than hardcode them in the code, I would like to put these in a plist in case they change. Here are a couple of the class methods:
+ (double) returnMinUsableFloatNumber
{
return 0.005;
}
+ (double) returnMaxUsableFloatNumber
{
return 129.11
}
I created a plist and kept it using a dictionary where I created a couple of keys: “minNumber” and “maxNumber.” However, the only datatypes for the values are “Bool, Data, Date, Number, String.” The number is an integer and cuts off any of the decimal that is inputted. While it is entirely possible to just store as a string and convert to a double later, is it possible to store a double as a value in the plist dictionary to eliminate this step?
Also, how do I access this dictionary since these are class methods and cannot use a dictionary instance variable to initialize with the dictionary used in the plist.
Ex:
+ (double) returnMinUsableFloatNumber
{
return \\ value returned from key "minNumber"
}
You need to store your
NSNumbervalues in plist in<real>tag:Then you can read them by initializing
NSDictionarywith contents of your plist file. Your methods will look like this: