2012-03-02 71 views
0

我有大约20行文本,需要有一些值,当我使用createFileAtPath创建文件模板?

[firstname] has a surname of [surname] 
and is [gender] 
etc etc etc 
etc etc etc 
etc etc etc 
etc etc etc 
and lives in [suburb] 

我有当用户点击一个按钮

创建该文件的次数可以这样通过创建某种模板或恒定的做,我可以用我的变量替换占位符?同样的事情也给NSString stringWithFormat称为像

[NSString stringWithFormat:myTemplate, person.firstname, person.surname, person.gender, person.suburb] 

回答

1

我想看看NSRegularExpression - replaceMatchesInString:选项:范围:withTemplate :.您可以匹配NSMutableString中的某些内容并将其替换。