我有一个像这样的长字符串:
je!tress:e?tu!tress:es?il!tress:e?nous!tress:ons?vous!tress:ez?ils!tress:ent?
Run Code Online (Sandbox Code Playgroud)
我想在之后分割字符串:之前?.所以我想进入数组:
{e,es,e,ons,ez,en}
Run Code Online (Sandbox Code Playgroud)
我知道我可以这样做:
NSArray *subStrings = [stringToChange componentsSeparatedByString:@":"];
Run Code Online (Sandbox Code Playgroud)
但这还不够.我怎么能这样做呢?任何帮助将不胜感激!
我有tableView一个custom cell.我有posibility保存到收藏夹中的一些内容,当发生这种情况我想补充一个明星image在cell.我试图这样做,但在明星出现后,我有一个问题.我认为这是因为reusable cell但我不知道如何解决它. 我的问题是: stars appear again on the other cells even if the word is not added on favorites.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
dictionaryTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
cell=[[dictionaryTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
}
if (tableView == self.searchDisplayController.searchResultsTableView)
{
cell.textLabel.text = [self.searchResult objectAtIndex:indexPath.row];
}
else
{
cell.word.text = self.tableData[indexPath.row];
BOOL isTheObjectThere = [self.favoriteArry containsObject:self.tableData[indexPath.row]];
if (isTheObjectThere==TRUE) {
cell.favImg.image=[UIImage imageNamed:@"3081@3x.png"];
}
}
return cell;
}
Run Code Online (Sandbox Code Playgroud) 我有一个搜索栏,我想检测用户何时单击它,以及在用户在搜索栏中编辑时禁用按钮.我怎么能这样做,因为我试图做什么,你会看到上面但它永远不会被召唤.
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
NSLog(@"yes");
}
Run Code Online (Sandbox Code Playgroud)
其他方法也searchDisplayController被称为.我也设置
self.searchBar.delegate=self
Run Code Online (Sandbox Code Playgroud)
但没有结果.