Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7572875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:02:32+00:00 2026-05-30T16:02:32+00:00

I just dived in the world of programming on the iOS platform and I

  • 0

I just dived in the world of programming on the iOS platform and I have made my first Hello World app.

I want to add extra functions to the app to learn more programming in Xcode.

In short, the apps adds the input you gave in the text field @ hallo and if you insert nothing it says Hello World!. (It adds World!)

Now I want the app to recognize a certain input so if I input a certain name (Kim) it gives not the standard response “hello Kim!” but for example hello Girl!.

This is the code that adds “world!” after “hello” if you let the input empty, so I figured this is the place to add some extra code for the extra feature.

This is the code I’m talking about in the HellowWorldViewController.m

- (IBAction)changeGreeting:(id)sender {

    self.userName = self.textField.text;

    NSString *nameString = self.userName;
    if ([nameString length] == 0) {
        nameString = @"World";
    }

    NSString *greeting = [[NSString alloc] initWithFormat:@"Hello, %@!", nameString];
    self.label.text = greeting;
}

This is what I came up with :

- (IBAction)changeGreeting:(id)sender {

    self.userName = self.textField.text;

    NSString *nameString = self.userName;
    if ([nameString length] == 0) {
        nameString = @"World";
    }
    if (String == "Kim") {
        nameString = @"Girl";
    }

    NSString *greeting = [[NSString alloc] initWithFormat:@"Hello, %@!", nameString];
    self.label.text = greeting;
}

I get two errors “Expected expression” and “Use of undeclared identifier ‘String’; did you mean ‘NSString’?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:02:36+00:00Added an answer on May 30, 2026 at 4:02 pm

    Change:

    if (String == "Kim") { nameString = @"Girl"; }
    

    to:

    if ([nameString isEqualToString:@"Kim"]) { nameString = @"Girl"; }
    

    You have two problems:

    String didn’t mean anything to your program, there is no variable or class called String. You probably just meant nameString.

    Strings need to be compared differently to using == so use isEqualToString instead.

    == checks for identity. That is whether the two objects are the same object and point to the same address in memory.

    isEqualTo by default does the same thing, but can be overridden to perform different equality comparisons. isEqualToString is just like this, but even more explicit.


    This might not be the only problem with your code but it’s the most obvious one I found.

    @Jim found another problem: Strings in objective-c start with an @ symbol.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just starting to learn Javascript; I do however have experience in programming using
I just dived into the world of using dispatch_queue a little bit more intensively
This is my first program I really created besides hello world. The code is
I have just dived into web services and trying to configure oracle soa suite
Just checking my JS and I have an error, but I cannot see where.
Just learning the world of jquery, and all my googling gives examples like this:
Just a knowledge question which I would like to ask: For example, I have
I have got a multi-threaded app that process a very large data file. Works
I'm just starting to dive into some basic Android development and have been experimenting
I have been programming mainly in PHP, and I am trying to make a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.