以下に示すコードの目的は、テキストフィールドから文字列を取得し、カンマと左括弧を削除して、内容を float に変換する準備をすることです。たとえば、数値 1,234,567 を 1234567 に変更します。
コード スニペットは機能しますが、「互換性のないポインター タイプが NSMutableString * from String * に割り当てられています」という情報エラーを返します。
NSMutableString の代わりに NSString を使用すると、エラーは発生しませんが、返される値は空の文字列です。
NSMutableString 方法論を使用して、何が問題で、これを変更して「互換性のないポインター型」エラーを解消するにはどうすればよいですか。
NSMutableString *cleanedDataCellTest = [[NSMutableString alloc] initWithString:datacellR2C2.text];
cleanedDataCellTest = [cleanedDataCellTest stringByReplacingOccurrencesOfString:@"," withString:@""];
cleanedDataCellTest = [cleanedDataCellTest stringByReplacingOccurrencesOfString:@")" withString:@""];
cleanedDataCellTest = [cleanedDataCellTest stringByReplacingOccurrencesOfString:@"(" withString:@"-"];
cleanedDataCellTest = [cleanedDataCellTest stringByReplacingOccurrencesOfString:@" " withString:@""];