Objective-C level-3

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 really nice");
}

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 but not really");
} else {
  NSLog(@"Mr. Higgie is definitely mean");
}

4 Equal strings

传递给 isEqualToString: 比较两个NSString,如果相同则会返回TRUE,反之返回FALSE。

可以用在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

switch使用的闪光点在与枚举结合使用。

typedef NS_ENUM(NSInteger, DayOfWeek) {
    DayOfWeekMonday = 1,
    DayOfWeekTuesday = 2,
    DayOfWeekWednesday = 3,
    DayOfWeekThursday = 4,
    DayOfWeekFriday = 5,
    DayOfWeekSaturday = 6,
    DayOfWeekSunday = 7
};
时间: 2024-10-10 23:34:12

Objective-C level-3的相关文章

HBV DNA level _data analysis

HBV 表明抗原阳性是HCC最重要风险因子 Seropositivity for the hepatitis B surface antigen (HBsAg) is one of the most important risk factors for hepatocellular carcinoma hbv e 抗原阳性会增加HCC风险 In our previous study, seropositivity for the hepatitis B e antigen (HBeAg) was

Higher level thinking

「Higher level thinking」-- 出自 Ray Dalio 的<Principles>(PDF 原文:Principles by Ray Dalio) Higher level thinking(高级别.高层次思维),实际上是一种理解起来非常简单且易于实行的方法论,即跳出以事实组成的现实世界(可以理解为现实生活),站在更高一层,系统地思考「低层」的现实世界,以实现个人目标为最终目的,设计出由「正确的人」和「正确的事情」所组成的「系统」(原文为「machine」,Ray 本人喜

修改Android Studio默认的API Level(SDK版本)

原文:修改Android Studio默认的API Level(SDK版本) Android Studio(2.1.2)新建工程的时候只会让你选择最低支持的SDK版本,默认的目标编译SDK版本会以系统当前SDK中最新SDK platform作为目标的API Level.但是很多时候我们并不需要最新的SDK版本,如何修改呢? 方法是:修改工程目录中的Gradle Scripts->build.gradle(Module:app)中的相关行,具体见下图: 当然也可以图形化操作,右键工程目录选择"

maven -- 问题解决(三)Java compiler level does not match the version of the installed Java project facet

问题: Java compiler level does not match the version of the installed Java project facet 解决方法如下: properties->Java Compiler,修改JDK版本,然后Apply

Train Herblore Level with 9% off 500M runescape gold shop on RSorder 8.19-8.24

When an employer conducts a background rs3 gold check on their own they will usually only get a hold of information on the location held, dates associated with employment and in case the candidate is entitled to rehire.The very Runescape Grand Switch

Java [Leetcode 107]Binary Tree Level Order Traversal II

题目描述: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example:Given binary tree {3,9,20,#,#,15,7}, 3 / 9 20 / 15 7 return its bottom-up level order

[LeetCode]Binary Tree Level Order Traversal II

Binary Tree Level Order Traversal II Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example:Given binary tree {3,9,20,#,#,15,7}, 3 / 9 20 / 15 7 re

Binary Tree Zigzag Level Order Traversal

原题: 题目解析:这个问题的实质是要我们按成访问二叉树的结点,并返回每层访问的结果,这里要求走Z字,其实就是一行正向一行反向. /* the kernel idea is visit a binary search tree in level and the additional work we have to label the end of one level. */ vector<vector<int> > zigzagLevelOrder(TreeNode *root) {

Type Java compiler level does not match the version of the installed Java project facet.项目内容没错但是项目上报错,不影响运行

1.Window->Show View->Problems 2.在项目上右键properties->project Facets->修改右侧的version  保持一致 3.window->preferences->Java->Compiler->设置右侧的Compiler compliance level 4.window->preferences->java->Installed JREs->设置或者选择右侧的Installed

Java_异常_02_java.lang.NoClassDefFoundError: org/apache/log4j/Level

总结:解析Json时,除了要导入json-lib-2.2-jdk15.jar外,还要导入: commons-beanutils.jar, commons-httpclient.jar, commons-lang.jar, ezmorph.jar, morph-1.0.1.jar 1.异常1信息: Failed to instantiate SLF4J LoggerFactory Reported exception: java.lang.NoClassDefFoundError: org/apa