0

i want to cancatenate strings with comma as a separator and result must be stored in string... comma=@","; for(i=0;i<[resources count];i++) { Record *aRecord = [resources objectAtIndex:i];

    temp=aRecord.programID;
    if(i==0)
        pid=temp;
    else
    //i am using this one to cancatenate but is not working why?

pid = [NSString stringWithFormat:@"%@%@%@", pid,comma,temp]; }

4

2 に答える 2

5

-componentsJoinedByString:でメソッドを使用しNSArrayます。

NSArray *csvArray = [NSArray arrayWithObjects:@"here", @"be", @"dragons", nil];
NSLog(@"%@", [csvArray componentsJoinedByString:@", "]);

ドキュメントから)

于 2010-08-14T15:29:27.593 に答える
1

id型をキャストしてからNSString、NSString のクラス参照にある連結メソッドを使用します。

于 2010-08-13T18:05:33.800 に答える