Objective-c Level-2

Source: Internet
Author: User


1 Sending a message


The real fun is accompanied by the "sending messages" began. Sending a message would be the basic building block of your objective-c apps because it's how do you tell an object to Perfor M some action or to give you some piece of information.



Sending a message requires two things-an object and a message name:


[ObjectName MessageName]; #Square brackets cannot be less


Send a simple message:


[TRYOBJC Completethischallenge];
2 Sending description information


Thetryobjcobject NSString isNSNumbersomething we made up and the objects built-in to Objective-c D NSArray, is real and has a bunch of messages you can send to them.



One of those messagesdescriptionis, and there's something extra cool about it-passing the message returns a result. Not all messages return something, but the message always returns a that represents the contents of thedescriptionNSStringobjec T that you passed the message to.



If you senddescriptiona NSString object, you'll get the characters in that string, and if you send it to a nsarray you ll Get a string containing all of the values in this array.


NSArray *foods = @[@"tacos", @"burgers"];

NSLog(@"%@", foods);

#output:
#challenge[3]: (
#    tacos,
#    burgers
#)
3 Storing the result of a message





Objective-c Level-2


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.