2012-03-02 67 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中的某些內容並將其替換。