用ios做的一個簡單的記事本

來源:互聯網
上載者:User

標籤:des   io   ar   os   sp   for   檔案   on   div   

#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.標題[email protected]"";    //使得開始輸入的時候 標題的文本text中清空
    self.文本[email protected]"";    //使得開始輸入的時候  文字框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做的一個簡單的記事本

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.