今天学习iOS开发中,关于textfield和textview的相关内容,其实也就是按照SAM ios6 application development 第7章中介绍的例子在编写了。其中程序的作用是可以读取textfield中的内容然后替换掉textview中标记出来的地方。
程序最后3行:
self.theStory.text = [self.theTemplate.text
stringByReplacingOccurrencesOfString:@"<place>" withString:self.thePlace.text];
NSLog(@"theStory:%@",self.theStory.text);
self.theStory.text = [self.theStory.text
stringByReplacingOccurrencesOfString:@"<verb>" withString:self.theVerb.text];
self.theStory.text = [self.theStory.text
stringByReplacingOccurrencesOfString:@"<number>" withString:self.theNumber.text];
刚开始的时候,我没有注意,将后两个语句中theStory写成了theTemplate,结果最后运行得到的结果都只是把<number>替换掉了,前两处标记都没有替换,当时没有仔细看,觉得很费解,后来就用NSLog 查看t