Je voudrais sortir des étiquettes pour chaque ligne avec différents noms de balises et je veux les enregistrer dans un fichier. Je peux écrire le fichier, mais c'est fini. Comment écrire chaque ligne dans un fichier différent?XML Tag xcode sauvegarder le fichier
Entrée:
anglais titanesque
leondradicapro kate
Allemand Hotel hüßßan
tomhanks angleina
Sortie:
<language>english<language/>
<movie>titanic<movie/>
<Actor>leondradiacpro<Actor/>
<Actress>kate<Actress/>
<language>German<language/>
...
code:
for (NSString *str in lineFile)
{
if([str hasPrefix:@"english "])
{
NSMutableArray *dd = [[NSMutableArray alloc] initWithArray:[[str stringByReplacingOccurrencesOfString:@"english" withString:@""] componentsSeparatedByString:@" "]];
NSArray *tag = [NSArray aarrayWithObjects:@"er",@"langauge",@"movie",@"actor",@"kate",nil];
NSMutableString *output =[[NSMutableString alloc] init];
NSUInteger tagindex =0;
for (NSString *words in word)
{
if(tagindex >=[tag count])
{
NSLog(@"dad");
break;
}
[output appendFormat:@"<%@>%@<%@>\n", [tag objectAtIndex:tagindex],words,[tag objectAtIndex:tagindex]];
NSLog(@"%@",output);
[output writeToFile:@"/Users/xx/Desktop/homework.txt" atomically:YES encoding:NSASCIIStringEncoding error:NULL];
tagindex++;
maintenant je peux en mesure de lire que la langue et le film (1ère ligne) comment je peux ajouter deuxième ligne et l'étiquette aussi