开发者

Remove brackets and quotes when displaying in textfield after using NSPredicate

开发者 https://www.devze.com 2023-04-03 23:46 出处:网络
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.

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 :)

0

精彩评论

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

关注公众号