Skip to content

Instantly share code, notes, and snippets.

@chyld
Created July 9, 2012 19:45
Show Gist options
  • Save chyld/3078475 to your computer and use it in GitHub Desktop.
Save chyld/3078475 to your computer and use it in GitHub Desktop.
iphone
#import <UIKit/UIKit.h>
@interface CMViewController : UIViewController
<UITextFieldDelegate>
{
NSMutableArray* words;
IBOutlet UITextField* mytext;
}
- (IBAction)addItem:(id)sender;
- (IBAction)deleteAll:(id)sender;
@end
------------------------------------------------
#import "CMViewController.h"
@interface CMViewController ()
@end
@implementation CMViewController
- (IBAction)addItem:(id)sender
{
[words addObject:mytext.text];
}
- (IBAction)deleteAll:(id)sender
{
words = [[NSMutableArray alloc] init];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment