Reputation: 11352
I have about 20 lines of text that needs to have some values in it replaced when I use createFileAtPath
e.g.
[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]
I have to create this file a number of times when a user clicks a button
Can this be done by creating some sort of template or constant where I can replace the placeholders with my variables? Something similar to NSString stringWithFormat
called like
[NSString stringWithFormat:myTemplate, person.firstname, person.surname, person.gender, person.suburb]
Upvotes: 0
Views: 63
Reputation: 1441
I would look at NSRegularExpression - replaceMatchesInString:options:range:withTemplate:. You can match something in a NSMutableString and replace it.
Upvotes: 1