Your first iOS app--Apple official iOS document learning

Source: Internet
Author: User

1 //2 //VIEWCONTROLLER.M3 //HelloWorld4 //5 // 6 //7 #import "ViewController.h"8 @interfaceViewcontroller ()9 @endTen @implementationViewcontroller One @synthesizeUsername=_username; A @synthesizeTextfield=_textfield; - @synthesizeLabel=_label; -- (void) Viewdidload { the     //[self settextfield:nil]; once initialized to null, when commented out, the label can normally get the value entered by the user.  -     //[self setlabel:nil]; Document 45 page description Add these may be to say what role, remember to delete, otherwise it will affect the label output after the display content.  -     //[Super Viewdidload]; -     //additional setup after loading the view, typically from a nib. + } -- (void) didreceivememorywarning { + [Super didreceivememorywarning]; A     //Dispose of any resources the can be recreated. at } --(Ibaction) Changegreeting: (ID) Sender { -Self.username =Self.textField.text; -NSString *namestring =Self.username; -NSLog (@"%@", namestring); -     if([namestring length] = =0) { inNamestring =@" World"; -NSLog (@"111"); to     } +NSLog (@"222"); -NSString *greeting = [[NSString Alloc]initwithformat:@"hello,%@!", namestring]; theNSLog (@"%@", greeting); *Self.label.text =greeting; $NSLog (@"333");Panax Notoginseng } --(BOOL) Textfieldshouldreturn: (Uitextfield *) thetextfield{ the     if(Thetextfield = =Self.textfield) { + [Thetextfield Resignfirstresponder]; A     } the     returnYES; +  - } $ @end

15, 16 lines is your first iOS App on the 45th page added up, with the Youdao translation software also did not suggest that the two sentences will affect the final case effect display. A lot of nslog output is added to the code to do the testing. There is a code output hint in the lower right corner of the second sheet. After 27 lines plus nslog, the output is (null), so it is judged that the user entered the content is not obtained. This good judgment problem appears, because of objective grammar unfamiliar, first annotated, a run, the result has become, the two sentences I have to carefully check.

Your first iOS app--Apple official iOS document learning

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.