A simple Notepad made with iOS

Source: Internet
Author: User

#import "ViewController.h"

@interface Viewcontroller ()
@property (Weak, nonatomic) iboutlet Uitextfield * title; With a text button.

@property (Weak, nonatomic) iboutlet Uitextview * text; A text View button is used


@end

@implementation Viewcontroller
-(Ibaction) Create: (ID) Sender {//Create a button button click to write
Self. Title [email protected] ""; The text of the caption is emptied when you start typing
Self. Text [email protected] ""; The text box is empty when you start typing
}
-(Ibaction) Save: (ID) Sender {//Create a button button to save the written text
NSString *name=self. title. Text; Assigns the input text in the caption to a pointer such as name
NSString *content=self. Text. Assigns the input in the text to a pointer such as content
NSString *path=[nsstring stringwithformat:@ "/users/apple/desktop/%@", name]; Give the "address" you want to save to a pointer variable of path
[Content Writetofile:path Atomically:yes encoding:nsutf8stringencoding error:nil];// Save the text content in the contents of the path in my book. If it doesn't exist, build it yourself.
}
-(Ibaction) read: (ID) Sender {
NSString *name=self. title. Text; Assigns the input text in the caption to a pointer such as name
NSString *path=[nsstring stringwithformat:@ "/users/apple/desktop/%@", name];//the "address" you want to save to a pointer variable of path
NSString *content=[nsstring Stringwithcontentsoffile:path encoding:nsutf8stringencoding error:nil];// Remove the file from the address to the content
Self. Text. text=content;//the text in the content is displayed in the text box of the text view
}

-(void) Viewdidload {
[Super Viewdidload];
Additional setup after loading the view, typically from a nib.
}

-(void) didreceivememorywarning {
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}

-(Ibaction) title: (ID) Sender {
}
@end

A simple Notepad made with iOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.