Search code examples
iosobjective-cline-breaksvcf-vcard

Creating a line break within vCard format


I am creating a vCard and among other things am including a note, like so

[vCardArray addObject:[NSString stringWithFormat:@"NOTE:%@", note]];

Then, as is standard procedure, creating a string from the array using "\n", like so

NSString *string = [vCardArray componentsJoinedByString:@"\n"];

The conflict arising is that my note string has a "\n" in it, which messes up the vCard representation. I have tried using "\r" both as the separator and within my note string, but to no avail.

Is there a way around this? I'd like to add a line of extra space in my note. Thanks in advance!


Solution

  • Newlines are represented as \n in vCard property values (as in: a backslash character, followed by an n character). So, you would have to replace all newlines characters with \n before assigning the string to the NOTE property.

    BEGIN:VCARD
    VERSION:3.0
    NOTE:Line 1\nLine 2\nLine 3
    END:VCARD