-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learning Swift Second Edition
By :

Objective-C has many of the same control flow paradigms as Swift. We will go through each of them quickly, but before we do, let's take a look at the Objective-C equivalent of print
:
var name = "Sarah" println("Hello \(name)") NSString *name = @"Sarah"; NSLog(@"Hello %@", name);
Instead of print
, we are using a function called NSLog
. Objective-C does not have string interpolation, so NSLog
is a somewhat more complex solution than print
. The first argument to NSLog
is a string that describes the format to be printed out. This includes a placeholder for each piece of information we want to log that indicates the type it should expect. Every placeholder starts with a percent symbol. In this case, we are using an at-symbol to indicate what we are going to be substituting in a string. Every argument after the initial format will be substituted for the placeholders in the same order they are passed in. Here, this means that it will end up logging Hello Sarah just like the Swift code...
Change the font size
Change margin width
Change background colour