The basics of dealing with string objects in Objective-C

New

Long-Term Learning

Learn efficiently and remember over time.

Start Long-Term Learning

Get personalized study reminders at intervals optimized for better retention.
Track your progress on this set by creating a folder
Or add to an existing folder

Add this set to a folder

  • Create a string called 'puppet' that has the value 'Pinocchio' without using message syntax (use the shorthand technique).

    NSString *puppet = @"Pinocchio";

    Create a string called 'puppet' that has the value 'Pinocchio' using message syntax

    NSString *puppet = [[NSString alloc] initWithString:@"Pinocchio"];

    Given: NSString *puppet = @"Pinocchio"; Write a line of code that stores the number of letters in 'puppet' in a variable called 'len'. Use message notation.

    unsigned long len = [puppet length]; (using 'int' for the data type here creates a warning)

    Given: NSString *school = @"TCA"; NSLog(@"I attend %@", school); The fragment '@"I attend %@"' is called a _____ ____ and the fragment '%@' is called a _____ or _____ _______

    format string...token...format specification

    In an NSLog statement, the token for a string is...

    %@

    In an NSLog statement, the token for an int is...

    %d

    In an NSLog statement, the token for a float is....

    %f

    In an NSLog statement, the token for a char is....

    %c

    Given: NSString fname = @"John"; NSString lname = @"Doe"; Write a command(s) that creates a new NSString called 'fullName' that concatenates fName and lName.

    NSString *fullName = [fname stringByAppendingString: @" "]; fullName = [fullName stringByAppendingString: lname];

    In an NSLog statement, the token for an unsigned long is....

    %lu

    Given: unsigned long len = [@"Hello World" length]; What is an acceptable replacement datatype for 'unsigned long'

    NSUInteger

    Correct the error: NSString temp = [[NSString alloc] init];

    NSString *temp = [[NSString alloc] init];

    Given: bool status = [TCAStringManip isUpperCaseLetter:t]; Write a statement that logs 'YES' if status is true and 'NO' if status is false using the ternary operator

    NSLog(@"%@", status? @"YES": @"NO");

    Please allow access to your computer’s microphone to use Voice Recording.

    Having trouble? Click here for help.

    We can’t access your microphone!

    Click the icon above to update your browser permissions above and try again

    Example:

    Reload the page to try again!

    Reload

    Press Cmd-0 to reset your zoom

    Press Ctrl-0 to reset your zoom

    It looks like your browser might be zoomed in or out. Your browser needs to be zoomed to a normal size to record audio.

    Please upgrade Flash or install Chrome
    to use Voice Recording.

    For more help, see our troubleshooting page.

    Your microphone is muted

    For help fixing this issue, see this FAQ.

    Star this term

    You can study starred terms together

    NEW! Voice Recording

    This is a Plus feature