Ajouter une chaîne avec une chaîne dans ios
Je suis dans un problème avec un partage de texte à evernote,le partage d'evernote est un succès,mais ici, c'est ma situation actuelle avec le code. J'ai un UITableView
qui a un peu de texte et un titre pour ce texte correspondant. Lorsque le bouton est cliqué, cela va partager le texte onebyone à evernote site web, mais le titre reste statique. Là, je reçois le premier titre nom avec diffrent texte. Mon code est dans mon tableview dans rowAtIndexPath
NSMutableString *strr=[[NSMutableString alloc]initWithString:[appDelegate.indexArray objectAtIndex:indexPath.section]];
cell.textLabel.text =strr ;
cell.textLabel.text = [appDelegate.indexArray objectAtIndex:row];
cell.textLabel.font = [UIFont fontWithName:@"Georgia" size:14.0];
cell.textLabel.textColor = [UIColor brownColor];
[appDelegate.notesArray objectAtIndex:row]];
//cell.detailTextLabel.text =notes;
cell.detailTextLabel.font = [UIFont fontWithName:@"Georgia" size:14.0];
cell.detailTextLabel.textColor = [UIColor darkGrayColor];
cell.detailTextLabel.text = [appDelegate.notesArray objectAtIndex:row];
appDelegate.indexArray
est le titre du contenu de chaque cellule et appDelegate.notesArray
a la textnote pour les titres correspondants.
Dans shareButton cliquez sur:
NSMutableString *str = [[NSMutableString alloc] initWithString:@"NOTES:"];
for (int i = 0; i<[appDelegate.notesArray count]; i++) {
NSString * aString = [[NSString alloc] initWithString:[appDelegate.notesArray objectAtIndex:i]] ;
NSString * ENML= [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">\n<en-note>%@",aString];
ENML = [NSString stringWithFormat:@"%@%@", ENML, @"</en-note>"];
NSLog(@"%@", ENML);
//Adding the content & resources to the note
[note setContent:ENML];
Cela vous donnera un par un téléchargement de notetext.mais pour le titre je inclure ce code
NSMutableString *strtitle = [[NSMutableString alloc] initWithString:@"myBibleApp"];
for (int i = 0; i<[appDelegate.indexArray count];i++ ) {
NSString * aStringtitle = [[NSString alloc] initWithString:[appDelegate.indexArray objectAtIndex:i]] ;
/* NSString *ENMLtitle = [NSString stringWithFormat:@"%@%@", aStringtitle];
NSLog(@"%@", ENMLtitle);*/
note.title = aStringtitle;
Mais voici mon problème c'uplode le titre et le texte en double. Cela signifie que, j'ai un texte avec le titre. Quand je clique sur le sharebutton il met deux fois.1=2,2=4,3=6 comme ça.
Écrou seulement addding le titre je reçois ce problème. Si j'ai mis le titre de la statique,de la note.title =@"statictitle". Il ne répétera pas les télécharger. Comment puis-je ajouter la chaîne de façon correcte?
S'il vous plaît aider moi.
Merci à l'avance.
source d'informationauteur stackiphone
Vous devez vous connecter pour publier un commentaire.
Deux choses que j'ai noté:
L'utilisation de NSMutableString n'est pas nécessaire. Il suffit d'écrire pour le premier cas
Pour les 2 autres cas, vous n'utilisez pas la chaîne à tous (ou il n'est pas indiqué dans votre code).
Pour les boucles, vous êtes toujours d'écraser aString et aStringtitle, et que même avec un nouveau alloc. Ajoutant va comme ceci:
ou
Vérifier la Classe NSString de Référence pour plus de détails.