Objective-C 中的字符串比较
如果无法实现这一点,我觉得真的很愚蠢。 我只是说,如果:在我的xml中标记,“tipo”包含“Colonnina”做一些事情
if ([[colonninaElencoFeed objectAtIndex:indexPath.row]objectAtIndex:@"tipo"] = @"Colonnina" ){
do something ...
}
当然我知道你不能写这样的语法,这个例子让我们更好地理解我正在尝试做的事情,
不用说XML 的写法是这样的
<tipo>Colonnina</tipo>
,我已经在使用这种方法从 xml 中推断数据,这样没有任何问题
cell.textLabel.text = [NSString stringWithFormat:@"%@", [[colonninaElencoFeed objectAtIndex:indexPath.row]objectForKey:@"title"]];
,我希望你能帮助我,谢谢
I feel really stupid not be able to achieve this if.
I simply say, if: tag in my xml, "tipo" contains "Colonnina" do something
if ([[colonninaElencoFeed objectAtIndex:indexPath.row]objectAtIndex:@"tipo"] = @"Colonnina" ){
do something ...
}
of course I know that you can not write so the syntax, this example brings us to better understand what I'm trying to do
needless to say that XML is written like
<tipo>Colonnina</tipo>
and I'm already using this method to extrapolate data from the xml such as this without any problem
cell.textLabel.text = [NSString stringWithFormat:@"%@", [[colonninaElencoFeed objectAtIndex:indexPath.row]objectForKey:@"title"]];
I hope you can help me, thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您尝试过使用
NSString isEqualToString:
吗?http://开发人员。 apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html
have you tried something with
NSString isEqualToString:
?http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html
比较字符串时,您应该使用 isEqualToString 方法。您的比较应该如下所示:
When comparing strings you should use isEqualToString method. Your comparison should look like this: