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 8036211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:32:38+00:00 2026-06-05T02:32:38+00:00

First I want to apologize for my lack of knowledge in programming in general.

  • 0

First I want to apologize for my lack of knowledge in programming in general. I am in the way of learning and have discovered that this site is a huge compliment for me of doing so.

I have created a program with three UITextField(thePlace,theVerb,theOutput) and two UITextView where one of the textviews(theOutput) take the text from the other textview(theTemplate) and replaces some strings with the text entered in the textfields.

When I click a button it triggers the method createStory that is listed below. This works fine with one exception. The text in the output only changes the string ‘number’ to the text in the textfield. However if I change the order in the method to replace ‘place’,’number’,’verb’ only the verb is changed, not the number.

Im sure this is some sort of easy fix but I can’t find it. Can some of you help me with my troubleshooting?

- (IBAction)createStory:(id)sender {
    theOutput.text=[theTemplate.text stringByReplacingOccurrencesOfString:@"<place>" withString:thePlace.text];
    theOutput.text=[theTemplate.text stringByReplacingOccurrencesOfString:@"<verb>" withString:theVerb.text];
    theOutput.text=[theTemplate.text stringByReplacingOccurrencesOfString:@"<number>" withString:theNumber.text];
}

Many thanks
// Emil

  • 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-06-05T02:32:41+00:00Added an answer on June 5, 2026 at 2:32 am

    The problem is that you’re overwriting the contents of theOutput.text with each line; var1 = var2; overwrites the data in var1 and replaces it with the contents of var2.

    Try this:

    - (IBAction)createStory:(id)sender 
    {
       NSString* tempStr = [theTemplate.text stringByReplacingOccurrencesOfString:@"<place>" withString:thePlace.text];
       tempStr = [tempStr stringByReplacingOccurrencesOfString:@"<verb>" withString:theVerb.text];
       theOutput.text = [tempStr stringByReplacingOccurrencesOfString:@"<number>" withString:theNumber.text];
    }
    

    Does this make sense? 🙂

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

Sidebar

Related Questions

First of all I want to apologize for my bad English. I have a
first of all I want to apologize about Title. I have one winform which
At first I want to apologize for my poor english. Is there any way
This is my first post on stack overflow, so I apologize if I have
First off, I apologize if this is a confusing or backwards way to go
First I want to apologize for such a silly question but I'm quite new
I want to apologize for my bad english first. I am trying to implement
First of all, i want to apologize for my poor English for it is
I have an object which I first want to rotate (about its own center)
First I want to describe my situation briefly. I have two classes, one MainClass

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.