如何在 iPhone 应用程序中显示搜索表中的第一个单词
嗨,我的 iPhone 应用程序中的每个应用程序都有一个搜索屏幕和一个搜索屏幕。我在搜索栏中有一些条目,例如 sudha、tharanga 和 Womensera(一些杂志),假设如果我们搜索板球特别版,它必须显示相应的杂志,
因此我计划使用如下所示的表格视图数据
sudha (cricket special, anna hazare special)
tharanga (footbal special,x special)
womens era (some y special)
,并将数据加载到表视图通过修剪括号 ( ) 之间存在的所有数据,我应该在表视图中显示剩余的数据
,那么我如何修剪字符串,以便它应该删除括号和括号符号中的数据
,以便我的表视图数据应该变成这样
sudha
tharanga
womens era
,提前谢谢
hii every one in my iphone app i have a search screen & i have some entries in the search bar like sudha, tharanga and womens era (some magazines ) suppose if we search cricket special, it has to show the respective magazine
so i planned to have the table view data like follows
sudha (cricket special, anna hazare special)
tharanga (footbal special,x special)
womens era (some y special)
and while loading data to the table view by trimming the all data which is present between the brackets ( ) and should i display remaining in the table view
so how can i trim the string in such a way that it should remove the data with in brackets and bracket symbols
so that my table view data should become like this
sudha
tharanga
womens era
, thanx in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关于根据您的要求修剪字符串,我想最简单的方法是使用
- (NSArray *)componentsSeparatedByString:(NSString *)separator
方法,如下所示;假设
theFullString = @"womensera (some yspecial)"
,结果数组的第一个元素将是@"womensera "
。我认为这工作正常。Regarding trimming the string as per your requirement, I guess the simplest way to go about it is to use the
- (NSArray *)componentsSeparatedByString:(NSString *)separator
method as follows;Assuming
theFullString = @"womens era (some y special)"
, the resulting arrays first element would be as@"womens era "
. I assume this works fine.使用此 nnstring 方法获得所需的结果,
或者您可以这样做,首先找到括号位置,
Use this nnstring method to get the desired result,
OR you can do that, first find bracket location,