I am using this code below my imports to define some info. I would like to instead use a plist to pull this info. How can I switch it over?
static NSUInteger kCGRectY = 520;
static NSUInteger kCGRectH = 340;
static NSString *kImage = @"Cover.png";
static NSString *kMImage = @"IMG_0172.JPG";
static NSString *kNames = @"WHO ELSE WORKED ON IT";
static NSString *kTitle = @"PROJECT DANDELION";
static NSString *kText = @"Lorem ipsum dolor sit amet, consectetur adipisicing elit";
In the code I use it like:
[pageView setImage:[UIImage imageNamed:kImage]];
UIImage *image = [UIImage imageNamed:kMImage];
CGSize size = [image size];
[colorView setFrame:CGRectMake(0, kCGRectY, size.width, kCGRectH)];
Any ideas?
An easy way would be to use the preprocessor to handle changing all of the code which accesses it, and have an object or class handle loading the information from the plist.
Replace the variable declarations with this code like this for each variable:
Then, in your application delegate, implement the
getStringForKey:method.Note that this code only handles strings, not numbers. If you want your numbers to also come from the plist, you could add them as strings and get the integer value: