Reputation: 636
I'm trying to post an itinerary to facebook as an attachment from my travel app, I'm using NSMutableString to append all the itinerary events and dates but I don't know how to give a line break after an event.
This is my code:
- (void)postItineraryToWall:(NSArray*)itineraryList{
NSMutableString *description = [NSMutableString string];
for (Itinerary *it in itineraryList) {
[description appendString:[NSString stringWithFormat:@"Evento: %@", it.event]];
[description appendString:[NSString stringWithFormat:@" en %@", it.place]];
[description appendString:[NSString stringWithFormat:@" el %@", it.eDate]];
}
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease]; dialog.userMessagePrompt = @"Enter your message:"; dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"Conectado desde TravelFan iPhone App\",\"caption\":\"Compartiendo itinerario\",\"description\":\"%@ \",\"media\":[{\"type\":\"image\",\"src\":\"http://www.site.com.mx/content/templates/default/images/logo_travel.jpg\",\"href\":\"http://www.site.com.mx/\"}]}", description]; dialog.actionLinks = @"[{\"text\":\"Obten App!\",\"href\":\"http://www.site.com.mx/\"}]"; [dialog show];
}
I tried using \n in the last string appended but since the attachment has already a string format with many \ and " when I test it it does not show the attachment text and if I test it without the \n it show everything but all in one line like this:
Event: expo at some museum 12/12/2011 12:00 Event: expo2 at some
museum 13/12/2011 13:00....
And I want it to appear like this:
Event: expo at some museum 12/12/2011 12:00
Event: expo2 at some museum 13/12/2011 13:00
....
EDIT: When I use \n and print with NSLog everything is the way I want but the attachment text does not appear in the facebook dialog screen, somehow the \n affects the whole attachment text.
Hope anybody can help me with this. Thanks in adevance!! XD
Upvotes: 0
Views: 1591
Reputation: 5172
Line breaks character for NSString is \r
correct way to use [NSString StringWithFormat:@"%@\r%@",string1,string2];
\r ----> carriage return
Upvotes: 0
Reputation: 159
Why you don't use this:
[description appendString:[NSString stringWithFormat:@"Evento: %@\n", it.event]];
Upvotes: 2