Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Interpolate with Format Strings #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions objc-interpolate/FISAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,40 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

*/

// A. DALEK //
NSLog(@"Dalek");
// String Interpolation
NSLog(@"%@", @"Dalek");
// String Interpolation via a Format string with five adjacent format specifiers
NSLog(@"%@%@%@%@%@", @"D", @"a", @"l", @"e", @"k");

// B. Interpolate //
// Print a string that says Interpolate!
NSLog(@"Interpolate!");
// Now, change the format string to a string literal containing only a single
// format specifier (%@) and use the "Interpolate!" string as the format argument
NSLog(@"%@", @"Interpolate!");
// Format string that contain two format specifiers separated by a space
NSLog(@"%@ %@", @"Interpolate!", @"Interpolate!");
// Format string that contain four format specifiers ending with an exclamation point (!)
NSLog(@"%@%@%@%@!", @"In", @"ter", @"po", @"late");
// Format string that contain four format specifiers ending with an exclamation point (!)
// but that separates each syllable with a dash (-)
NSLog(@"%@-%@-%@-%@!", @"In", @"ter", @"po", @"late");

// C. "You are not The Doctor!"
// print a string
NSLog(@"You are not The Doctor!");
// use a single format specifier (%@) in the format string to interpolate the string
NSLog(@"%@", @"You are not The Doctor!");
// Separates each word into a single string that gets interpolated into the
// format string as the list of format arguments
NSLog(@"%@%@%@%@%@%@", @"You", @"are", @"not", @"the", @"Doctor", @"!");
// Now, add spaces except for the exclamation mark at the end
NSLog(@"%@ %@ %@ %@ %@%@", @"You", @"are", @"not", @"the", @"Doctor", @"!");
// Mix and match
NSLog(@"You are %@ %@!", @"not", @"The Doctor");

// Do not alter
return YES; //
///////////////
Expand Down