ios - 如何检查我的NSMutableOrderedSet中是否存在我的NSString?

标签 ios objective-c nsmutablearray twilio-programmable-chat nsmutableorderedset

我从第三方SDK之一获得以下响应,现在如何检查响应中是否存在我的String值?和我需要与friendlyName键比较的键。

 channelList = (
     "<<TCHChannel: 0x2816df040>: sid: 'CH84', friendlyName: 'Mihir : MihirOza', attributes: '(null)'>",

     "<<TCHChannel: 0x2816dc480>: sid: '644d', friendlyName: 'Testchannel2', attributes: '(null)'>",

     "<<TCHChannel: 0x2816dff40>: sid: 'df38', friendlyName: 'privateios', attributes: '(null)'>" )  

这是我正在使用的代码。
TCHChannels *channelsList = [[[ChatManager sharedManager] client] channelsList];
NSMutableOrderedSet<TCHChannel *> *newChannels = [[NSMutableOrderedSet alloc] init];
[newChannels addObjectsFromArray:[channelsList subscribedChannels]];
NSMutableArray<TCHChannel *> *temp = [[NSMutableArray alloc] initWithArray:[newChannels array]];
NSLog(@"channelList = %@",temp);

提前致谢。

最佳答案

尝试这个 :

NSPredicate *Pred = [NSPredicate predicateWithFormat:
                          @"TCHChannel.friendlyName == 'yourstring'"];
NSArray *arr = [temp filteredArrayUsingPredicate:pred];

关于ios - 如何检查我的NSMutableOrderedSet中是否存在我的NSString?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59786728/

相关文章:

iphone - NSTimer在其他线程中不起作用

ios - 在 iOS 中将两个文本字段添加/连接到一个标签中

ios - 将自定义对象添加到 NSMutableArray

ios - 即使我添加了委托(delegate),iAd 也无法正常工作

php - iOS上传图片php返回空

ios - 纯代码关于UICollectionView水平分页

objective-c - iOS NSMutableArray insertObject 索引越界

iphone - 扫描 NSMutableArray 以获取字符串的一部分

ios - Xcode 7.1 beta 2 - 禁用 ATS

ios - 如何在可编辑和不可编辑之间切换 UILabel