I got a slight problem, I'm getting a error saying "'UIPickerView' undeclared on line 1 of the below code. I copied right out of the book that I have and I'm not sure whats wrong? could I get some help? it would be greatly appreciated, thanks :)
this is the entire .m file code.
#import "InstatwitViewController.h"
@implementation InstatwitViewController
- (void)viewDidLoad {
[super viewDidLoad];
activities = [[NSArray alloc] initWithObjects:@"sleeping",
@"eating", @"working", @"thinking", @"crying", @"begging",
@"leaving", @"shopping", @"hello worlding", nil];
feelings = [[NSArray alloc] initWithObjects:@"awesome",
@"sad", @"happy", @"ambivalent", @"nauseous", @"psyched",
@"confused", @"hopeful", @"anxious", nil];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)
pickerView {
return 2;
}
- (NSInteger)PickerView:(UIPickerView *)pickerViewnumberOfRowsInComponent : (NSInteger)component {
if (component == 0) {
return [activities count];
}
else {
return [feelings count];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
switch (component) {
case 0:
return [activities objectAtIndex:row];
case 1:
return [feelings objectAtIndex:row];
}
return nil;
}
}
- (void)dealloc {
[activities release];
[feelings release];
[super dealloc];
}
@end
Where did you copy it? It should be in the @implementation
... @end
section of the .m
file of the class you are implementing. It should not be in the @interface
... @end
part, which is typically in a .h
file, or elsewhere, i.e. outside the @implementation
... @end
section.
Please show a little more of your code.
This:
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
lacks a closing }
before - (NSString *)pickerView: ...
. In other words, change it thus:
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {