I iterate trough an Array like that.
NSArray *array = [[currentRaum raumattribute] allObjects];
NSString *compositeString = [ [ NSString alloc ] init ];
for( Raumattribute *attr in array ){
compositeString = [ NSString stringWithFormat:@"%@ %@",compositeString, attr.attributname ];
[raumAttributLabel setText:compositeString];
I want a output like that —-> Cat,Dog,Mouse
But if i do this:
compositeString = [ NSString stringWithFormat:@"%@ %@,",compositeString, attr.attributname ];
the output is Cat,Dog,Mouse,
or if i do this like that:
compositeString = [ NSString stringWithFormat:@"%@ ,%@",compositeString, attr.attributname ];
the output its ,Cat,Dog,Mouse
Is there a solution?
You can do that using array’s
valueForKey:andcomponentsJoinedByString:methods:valueForKey:will create array of attributname values for each array elementcomponentsJoinedByString:will join those values into one string separated by commas