Ø (23)Saving
and Retriving Data in iphone(IOs)
Save.h
@property (nonatomic, retain) IBOutlet UITextField
*myTxtFld;
- (IBAction)saveButtonPressed:(id)sender;
- (IBAction)showMyData:(id)sender;
Save.m
@synthesize myTxtFld;
- (IBAction)saveButtonPressed:(id)sender
{
[myTxtFld
resignFirstResponder];
[[NSUserDefaults
standardUserDefaults] setValue:myTxtFld.text forKey:@"MyData"];
}
- (IBAction)showMyData:(id)sender
{
NSString *myData =
[[NSUserDefaults standardUserDefaults] valueForKey:@"MyData"];
[[[UIAlertView
alloc] initWithTitle:@"My Data"
message:myData
delegate:nil
cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}
No comments:
Post a Comment