开发者

How insert linebreaks in NSString for Facebook stream.publish

开发者 https://www.devze.com 2023-02-04 04:59 出处:网络
I saw some applications on Facebook can post to user wall mess开发者_开发技巧ages with linebreaks - like that:

I saw some applications on Facebook can post to user wall mess开发者_开发技巧ages with linebreaks - like that:

  1. blablabla
  2. blablabla etc

My code put this text on Facebook - "1. blablabla 2. blablabla etc" How can I insert linebreak in description part of stream.publish in Facebook

\n - is not working

My code is

- (void)publishTopToStream{

NSMutableString *topTenArrayString=[[NSMutableString alloc] initWithFormat:@""];

for (int i=0; i<7; i++) {
    NSString *tempString = [[NSString alloc] initWithFormat:@"%d. %@\n ",i+1,[[topTenArray objectAtIndex:i]  personName]];
    [topTenArrayString appendString:tempString];    
    [tempString release];
}

SBJSON *jsonWriter = [[SBJSON new] autorelease];

NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
                            @"Top 7 friends", @"name",
                            @"Top 7 friends", @"caption",
                            topTenArrayString, @"description",
                            @"http://www.qqq.net/", @"href",
                            nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               kAppId, @"api_key",
                               @"Share on Facebook",  @"user_message_prompt",
                               attachmentStr, @"attachment",
                               nil];

[_facebook dialog: @"stream.publish"
        andParams: params
      andDelegate:self];}


I don't know if this will work, but have you tried \r ? It's a carriage return, as opposed to a line feed.


I use properties, for example:

attachment = { 
            name: Super Application Posr
            href: 'http://apps.facebook.com/superapplication/',
            caption: 'blahh blahh',
            description: 'Here is a list of the top Smelly people in the world' ,
            properties: {
                    1: "Mr Moo",
                    2: "Mrs Moo",
                    3: "Mr Sheep",
                    4: "me"
                    }
              } 

P.S ^^Javascript, but you get the idea

0

精彩评论

暂无评论...
验证码 换一张
取 消