Как объединить строки из массива NSMutable - PullRequest
0 голосов
/ 06 марта 2012

Я пытаюсь выяснить, как объединить данные из массива NSMutable, чтобы они были частью тела письма.Следующий код создает следующий вывод NSLog:

- (void)emailBody
{
    NSLog(@"Number of Songs: %@", profile.profileNumberOfSongs);
    NSLog(@"Profile Length:  %@", [self convertSecondstoMMSS:[profile.profileDuration intValue]]);

    for (ProfileItems *item in profileItemsNSMArray) 
    {
        NSLog(@"%@ %@ - %@ %@", item.profileItemsSongOrder, item.profileItemsMovementName, item.profileItemsArtist, item.profileItemsSong);
    }
}

Вывод NSLog:

 Number of Songs: 9
 Profile Length:  40:07
 1 Seated Flat - Foo Fighters Home
 2 Seated Flat - Foo Fighters What If I Do?
 3 Standing Climb - Foo Fighters Tired Of You

Каков наилучший способ сохранить эти данные в одну строку NSString, которая будет передана в телописьма?

Заранее спасибо

-Paul

1 Ответ

0 голосов
/ 06 марта 2012
- (NSString *)emailBody
{
    NSMutableString *emailBodyString = [NSMutableString string];
    [emailBodyString appendFormat:@"Number of Songs: %@", profile.profileNumberOfSongs];
    [emailBodyString appendFormat:@"Profile Length: %@", [self convertSecondstoMMSS:[profile.profileDuration intValue]]];

    for (ProfileItems *item in profileItemsNSMArray) 
    {
        [emailBodyString appendFormat:@"%@ %@ - %@ %@", item.profileItemsSongOrder, item.profileItemsMovementName, item.profileItemsArtist, item.profileItemsSong];
    }

    return emailBodyString;
}
...