I'm trying to make a simple joke app but when I launch the app in the simulator, nothing comes up in the UITextField. Can any of you experienced iPhone programmers please help me?
Here is my .h file :
And here is my .m file. I have yet to write the buttonPressed method but since it will be almost identical to viewDidLoad I don't suppose it'll be a problem.
Here is a picture of the .plist I'm using:
I don't suppose screenshots of my IB project is need, it's just a background, a UITextView and a button and everything is linked, but if you do, I can add some screenshots.
P.S. It is the first time I'm dealing with the UITextView class, but I don't suppose I need to implement any protocols if all I use it for is displaying text???
P.P.S. This app is in danish. "vittighed" means joke and "vittigheder" means jokes. Just thought you'dd like to know
- Ben
Here is my .h file :
Code:
#import <UIKit/UIKit.h>
@interface iVittighederViewController : UIViewController {
IBOutlet UITextView *jokeTextView;
NSDictionary *jokeDictionary;
NSString *lastJoke;
}
@property (retain, nonatomic) UITextView *jokeTextView;
@property (retain, nonatomic) NSDictionary *jokeDictionary;
@property (retain, nonatomic) NSString *lastJoke;
- (IBAction)buttonPressed:(id)sender;
@end
And here is my .m file. I have yet to write the buttonPressed method but since it will be almost identical to viewDidLoad I don't suppose it'll be a problem.
Code:
#import "iVittighederViewController.h"
@implementation iVittighederViewController
@synthesize jokeTextView;
@synthesize jokeDictionary;
@synthesize lastJoke;
- (IBAction)buttonPressed:(id)sender
{
}
- (void)viewDidLoad
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *vittighederPlistPath = [bundle pathForResource:@"vittigheder" ofType:@"plist"];
NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:vittighederPlistPath];
self.jokeDictionary = dictionary;
[dictionary release];
NSArray *array = [self.jokeDictionary allKeys];
int number = random() % [array count];
NSString *theString = [[NSString alloc] initWithFormat:@"vittighed%i", number];
NSString *output = [jokeDictionary valueForKey:theString];
jokeTextView.text = output;
lastJoke = theString;
srandom(time(NULL));
[theString release];
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)dealloc {
[super dealloc];
}
@end
Here is a picture of the .plist I'm using:
I don't suppose screenshots of my IB project is need, it's just a background, a UITextView and a button and everything is linked, but if you do, I can add some screenshots.
P.S. It is the first time I'm dealing with the UITextView class, but I don't suppose I need to implement any protocols if all I use it for is displaying text???
P.P.S. This app is in danish. "vittighed" means joke and "vittigheder" means jokes. Just thought you'dd like to know
- Ben