用ios做的一个简单的记事本
2014-11-29 16:06
363 查看
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *标题; //用的是一个text按键
@property (weak, nonatomic) IBOutlet UITextView *文本; //用的是一个text view按键
@end
@implementation ViewController
- (IBAction)创建:(id)sender { //创建的是一个button按键 点击就可以进行书写了
self.标题.text=@""; //使得开始输入的时候 标题的文本text中清空
self.文本.text=@""; //使得开始输入的时候 文本框text view清空
}
- (IBAction)保存:(id)sender { //创建的一个button按键 用以保存已经写的文本
NSString *name=self.标题.text; //将标题中的输入文本赋值给name这样的一个指针
NSString *content=self.文本.text; //将文本中的输入内容赋值给content这样的一个指针
NSString *path=[NSString stringWithFormat:@"/Users/apple/Desktop/%@",name]; //将你要保存的“地址”给一个path的指针变量
[content writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];//将content中的文本内容保存在path我那本中.如果不存在则自行建立
}
- (IBAction)读取:(id)sender {
NSString *name=self.标题.text; //将标题中的输入文本赋值给name这样的一个指针
NSString *path=[NSString stringWithFormat:@"/Users/apple/Desktop/%@",name];//将你要保存的“地址”给一个path的指针变量
NSString *content=[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];//把地址中的文件取出来给content
self.文本.text=content;//将content中的文本显示在text view的文本框中
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)标题:(id)sender {
}
@end
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *标题; //用的是一个text按键
@property (weak, nonatomic) IBOutlet UITextView *文本; //用的是一个text view按键
@end
@implementation ViewController
- (IBAction)创建:(id)sender { //创建的是一个button按键 点击就可以进行书写了
self.标题.text=@""; //使得开始输入的时候 标题的文本text中清空
self.文本.text=@""; //使得开始输入的时候 文本框text view清空
}
- (IBAction)保存:(id)sender { //创建的一个button按键 用以保存已经写的文本
NSString *name=self.标题.text; //将标题中的输入文本赋值给name这样的一个指针
NSString *content=self.文本.text; //将文本中的输入内容赋值给content这样的一个指针
NSString *path=[NSString stringWithFormat:@"/Users/apple/Desktop/%@",name]; //将你要保存的“地址”给一个path的指针变量
[content writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];//将content中的文本内容保存在path我那本中.如果不存在则自行建立
}
- (IBAction)读取:(id)sender {
NSString *name=self.标题.text; //将标题中的输入文本赋值给name这样的一个指针
NSString *path=[NSString stringWithFormat:@"/Users/apple/Desktop/%@",name];//将你要保存的“地址”给一个path的指针变量
NSString *content=[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];//把地址中的文件取出来给content
self.文本.text=content;//将content中的文本显示在text view的文本框中
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)标题:(id)sender {
}
@end
相关文章推荐
- 【IOS】利用ASIHTTPRequest 实现一个简单的登陆验证
- 代码---模拟一个简单的记事本
- 如何用PHP/MySQL为 iOS App 写一个简单的web服务器(译) PART1
- ios tableView那些事(一)创建一个简单的tableView
- Racket 语言编写的一个简单记事本程序
- iOS简单加载一个网页
- java编写一个简单记事本
- IOS第二十天——实现一个简单的表
- ios学习笔记block回调的应用(一个简单的例子)
- iOS简单加载一个网页
- 九十、创建 一个简单的iOS应用程序
- iOS: 一个简单免费的MDM
- iOS: 一个简单免费的MDM
- 【iOS开发】 CoreText 使用教程:以创建一个简单的杂志应用为例
- 创建一个简单的 iOS 5 iPhone App 教程(2/3)
- IOS学习笔记之实现一个简单的表
- win32sdk学习 richedit实现的一个简单记事本
- 构建一个简单的ios应用程序
- 如何用PHP/MySQL为 iOS App 写一个简单的web服务器(译) PART1
- 【iOS开发】 CoreText 使用教程:以创建一个简单的杂志应用为例