Objective-c level-3

Source: Internet
Author: User
Tags switch case

1 if
Mrhiggieismean = NO; if (Mrhiggieismean) {  NSLog (@ "confirmed:he is super mean");}

2 if Else
BOOL Mrhiggieismean = [Mrhiggie Areyoumean]; if (Mrhiggieismean) {  NSLog (@ "confirmed:he is super mean");} Else {  NSLog (@ "No, actually he ' s reallynice");}

3 If-else If-else
NSNumber *meannessscale =[Mrhiggie Meannessscale];if([Meannessscale Intvalue] <4) {NSLog (@"Mr. Higgie is on the nice side");} Else if([Meannessscale Intvalue] <8) {NSLog (@"Mr. Higgie is sorta nice and not really");} Else{NSLog (@"Mr. Higgie is definitely mean");}

4 Equal Strings

Passed to isequaltostring: compares two nsstring, returns True if same, and returns false instead.

Can be used in the conditional judgment of if:

if ([myString isequaltostring:otherstring]) {  NSLog (@ "Hello from inside the if! " );}
5 Switch case
Nsinteger Day =GetDayOfWeek ();Switch(day) { Case 1: {NSLog (@"Monday");  Break; }   Case 2: {NSLog (@"Tuesday");  Break; }  /*snip Wednesday through Saturday*/   Case 7: {NSLog (@"Sunday");  Break; }}
6 Switch on Enums

The flash used by switch is used in conjunction with enumerations.

typedef ns_enum (Nsinteger, DayOfWeek) {    1,    2,    3 ,     4 ,     5 ,     6 ,     7 };

Objective-c level-3

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.