对代码的一点解释:我有一个看起来像这样的字典:
HC_1 : test1, HC_2: test2, ....
如果我在“theModifiedReportTemplateContent”中找到HC_1,我会查找第一个“>”之后我加上“test1”。
-(NSMutableString*)almMapData:(NSDictionary *)aDictData;
{
NSMutableString *theModifiedReportTemplateContent = itsReportTemplateContent mutableCopy];
for(id theCell in aDictData)
{
NSRange theNameRange = [theModifiedReportTemplateContent rangeOfString:theCell];
NSString *theNewContent = [theModifiedReportTemplateContent substringFromIndex:theNameRange.location];
if(theNameRange.location != NSNotFound)
{
NSRange theCharRange = [theNewContent rangeOfString:@">"];
long theIndex =((long)theCharRange.location+(long)theNameRange.location+1);
[theModifiedReportTemplateContent insertString:[aDictData objectForKey:theCell] atIndex:theIndex];
}
}
return theModifiedReportTemplateContent;
}
我的问题是我们打印了theCharRange,我有类似的东西:
location=13, length=1
{
2001-01-01 00:00:00 +0000
<object returned empty description>
}
所以我对InsertString atIndex有一个例外。