【发布时间】:2012-07-28 23:46:50
【问题描述】:
下面显示的代码的目的是从文本字段中获取一个字符串并删除逗号和左括号,以准备将内容转换为浮点数。例如,它将数字 1,234,567 更改为 1234567。
代码 sn-p 有效,但返回信息性错误“不兼容的指针类型分配给 NSMutableString * from String *”
当我使用 NSString 而不是 NSMutableString 时,我没有收到任何错误,但返回的值是一个空字符串。
使用 NSMutableString 方法,有什么问题以及如何更改它以消除“不兼容的指针类型”错误。
NSMutableString *cleanedDataCellTest = [[NSMutableString alloc] initWithString:datacellR2C2.text];
cleanedDataCellTest = [cleanedDataCellTest stringByReplacingOccurrencesOfString:@"," withString:@""];
cleanedDataCellTest = [cleanedDataCellTest stringByReplacingOccurrencesOfString:@")" withString:@""];
cleanedDataCellTest = [cleanedDataCellTest stringByReplacingOccurrencesOfString:@"(" withString:@"-"];
cleanedDataCellTest = [cleanedDataCellTest stringByReplacingOccurrencesOfString:@" " withString:@""];
【问题讨论】:
-
哪一行给出警告?
标签: ios