Only last row in method execute (Objective-C)

Posted by Emil on Stack Overflow See other posts from Stack Overflow or by Emil
Published on 2012-06-04T22:35:28Z Indexed on 2012/06/04 22:40 UTC
Read the original article Hit count: 304

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about ios