1

I would like to create a plug-in necessary for our hospital, but I have never coded in Objective-C. I have been looking at many examples but cannot see how to select a specific word into a file to change it.

I want to select the word MRSC that is written on a line beginning with 0008,0060 and change it to MR (to tell our server that this file was sent by a MRI machine, which is necessary to archive it). I know how I can change the word, using NSMutableArray, but I don't know how to select my MRSC. How can I do this?

4

1 回答 1

0

沿着这些思路,假设 ARC 或 GC 内存管理:

NSString *inputLine = ... ; // the line you've read in

if ([inputLine hasPrefix:@"0008,0060") // is it a line needing changing?
{
   // replace MRSC with MR and store result in same variable
   inputLine = [inputLine stringByReplacingOccurencesOfString:@"MRSC" withString:@"MR"];
}

如果您愿意,您也可以使用可变字符串来执行此操作,在这种情况下几乎没有什么区别。

于 2012-05-25T09:44:33.980 回答