【问题标题】:Replacing value with string in objective c用目标c中的字符串替换值
【发布时间】:2016-05-05 11:27:28
【问题描述】:

我想用文本字段站中的字符串 MyPostition 替换 placemark.name 的值,但是这行代码不起作用请提供任何建议

 _station.text = [NSString stringWithFormat:@"%@",placemark.name];
 _station.text=[NSString stringWithFormat:@"%@",@"MyPosition"];

【问题讨论】:

  • 我想你试过这个_station.text=[NSString stringWithFormat:@"MyPosition %@",placemark.name];
  • 你能把这个问题说清楚一点吗??
  • 使用字符串替换OccuranceofString
  • 您遇到了错误或其他问题,请提供详细信息
  • 兄弟你需要什么输出

标签: ios objective-c google-geocoder


【解决方案1】:

如果MyPosition 是您要从中设置值的变量,请从该变量中删除",如下所示:

_station.text=[NSString stringWithFormat:@"%@",MyPosition];

按照您的要求进行更新:

_station.text = [NSString stringWithFormat:@"%@",placemark.locality];

【讨论】:

    【解决方案2】:

    请尝试此代码。它可能对你有用

        NSString *str = @"This is a MyPosition";
    
       str = [str stringByReplacingOccurrencesOfString:@"MyPosition"
                                     withString:@"duck"];
    

    【讨论】:

      【解决方案3】:

      使用这种格式:

      _station.text = [NSString stringWithFormat:@"%@",placemark.locality];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-09-23
        • 2018-03-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-20
        • 2019-05-09
        • 1970-01-01
        相关资源
        最近更新 更多