【发布时间】:2012-02-29 17:36:12
【问题描述】:
所以我需要将在文本字段中输入的任何内容保存到 nsmutablearray 中(这必须发生多次!并且每次都必须保存为另一个对象)。但无论我做什么显然都不起作用,因为它说“文本”不在结构或联合中。这是我的代码。感谢您的任何意见!
问题在于输入的ClassText 方法。
#import "EnteringCoursesViewController.h"
#import "SelectRotationController.h"
@implementation EnteringCoursesViewController
@synthesize classField;
@synthesize indicatedClass;
@synthesize labelClassTitle;
@synthesize selectRotationController;
@synthesize classesEnteredTable;
- (IBAction)chooseType {
UIActionSheet *typeSheet = [[UIActionSheet alloc]
initWithTitle:@"Class types"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"Core Class", @"Elective", nil];
[typeSheet showInView:self.view];
[typeSheet release];
}
- (void)actionSheet:(UIActionSheet *)typeSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0) {
self.indicatedClass = classField.text;
NSString *indicatedString = indicatedClass;
NSString *greeting = [[NSString alloc]
initWithFormat:@"%@ meets 6 times per rotation", indicatedString];
labelClassTitle.text = greeting;
labelClassTitle.hidden = NO;
[greeting release];
[indicatedClass release];
}
else if (buttonIndex == 1) {
self.indicatedClass = classField.text;
NSString *indicatedString = indicatedClass;
NSString *greeting = [[NSString alloc]
initWithFormat:@"%@ meets 3 times per rotation", indicatedString];
labelClassTitle.text = greeting;
labelClassTitle.hidden = NO;
[greeting release];
[indicatedClass release];
}
}
- (IBAction)chooseFirstMeeting:(id)sender {
SelectRotationController *selectView = [[SelectRotationController alloc]
initWithNibName:@"SelectRotationController"
bundle:[NSBundle mainBundle]];
[selectView.navigationItem setTitle:@"First Period Day Choose"];
[self.navigationController pushViewController:self.selectRotationController animated:YES];
self.selectRotationController = selectView;
[selectView release];
}
- (IBAction)enteredClassText:(id)sender {
NSMutableArray *classesEntered = [NSMutableArray arrayWithObject:sender.text];
[classesEntered = [NSMutableArray alloc] init];
[classesEntered release];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidLoad {
self.navigationItem.hidesBackButton = YES;
[super viewDidLoad];
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[classField release];
[labelClassTitle release];
[indicatedClass release];
[selectRotationController release];
[classesEnteredTable release];
[super dealloc];
}
@end
【问题讨论】:
标签: objective-c object nsmutablearray uitextfield