Hey I'm trying to make a joke shuffler app but can't the simple part of my code correct. Here it is...
Code:
#import "JokesAppDelegate.h"
@implementation JokesAppDelegate
- (void)readPlist
{
NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"Jokes" ofType:@"plist"];
self.data = [NSArray arrayWithContentsOfFile:dataPath];
NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:dataPath];
value = [plistDict objectForKey:@"test"];
/* You could now call the string "value" from somewhere to return the value of the string in the .plist specified, for the specified key. */
}
@synthesize window;
@synthesize tabBarController;
@synthesize value;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
label.text = value;
And Here's the header
Code:
#import <UIKit/UIKit.h>
@interface JokesAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
IBOutlet UILabel *label;
NSString *value;
NSArray *data;
}
@property (nonatomic, retain) NSString *value;
@property (nonatomic, retain) NSArray *data;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@end
Above, I am trying to find the key "test" in my jokes.plist and get it's value to be displayed in the label but nothing is showing up on the label when I Build and Go.
P.S. As obvious from above I am using a tabbarcontroller
Pls Help