Remove brackets and quotes when displaying in textfield after using NSPredicate
I would like to remove the brackets and quotes when it displays in textfield. I am using NSPredicate to get the contents that I want.
Here is my code:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Block == '1234'"];
NSArray *predicateArray 开发者_JS百科= [blockStage filteredArrayUsingPredicate:predicate];
predicateStreetName = [predicateArray valueForKey:@"Street Name"];
streetName.text = [NSString stringWithFormat:@"%@", predicateStreetName];
Here is how it displays in the textfield:
(
"Street Name Value"
)
This code displays the street name value that I want, but however, it displays with the brackets and quotes. How do I remove them?
Thank you in advance!!
take a look at this Convert NSArray to NSString in Objective-C this answer Convert NSArray to NSString in Objective-C, the ' componentsJoinedByString:@"" ' will help solve your problem. Do it here:
streetName.text = [[NSString stringWithFormat:@"%@", predicateStreetName] componentsJoinedByString:@""];
kuddos, aimzy :)
精彩评论