我的 iPhone 应用程序崩溃并显示错误:
- [__NSCFDictionary stringByReplacingOccurrencesOfString:withString:]: unrecognized selector sent to instance 0x99f60b0
这是我的代码 NSString *strData; AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; if (delegate.respondInsightIndex) { strData = [insights objectAtIndex:index]; } else { strData = [洞察lastObject];
}
NSString *strReplace = [NSString stringWithFormat:@"%@",[strData stringByReplacingOccurrencesOfString:@"%20" withString:@" "]];
这是我再次发生崩溃的方法
- (void) setComments:(NSArray*)comments {
NSString * htmlString;
if ( [UIHelper isPad] )
htmlString = @"<html><style type=\"text/css\">body{padding:15px 40px 0 40px; font-family: Helvetica;"
"font-size: 14px;"
"color: #888888;"
"line-height: 50%"
"},</style><body>";
else
htmlString = @"<html><style type=\"text/css\">body{padding:8px 20px 0 20px; font-family: Helvetica;"
"font-size: 11px;"
"color: #888888;"
"},</style><body>";
for ( NSString * single in comments ) {
if ( single == nil )
single = @"";
if ([single isKindOfClass:[NSString class]]) {
single = [single stringByReplacingOccurrencesOfString:@"%20" withString:@" "];
}
NSString * str ;
if([UIHelper isPad ])
{
str = [NSString stringWithFormat:@"%@<br/><hr color=#555555><p align=\"right\" style=\"font-size:12px;\">Username</p>", single];
}
else {
str = [NSString stringWithFormat:@"%@<br/><hr color=#555555><p align=\"right\" style=\"font-size:9px;\">Username</p>", single];
}
htmlString = [NSString stringWithFormat:@"%@%@", htmlString, str];
}
htmlString = [NSString stringWithFormat:@"%@%@", htmlString, @"</body></html>"];
if ( [contentView respondsToSelector:@selector(loadHTMLString:baseURL:)] )
[contentView loadHTMLString:htmlString baseURL:[NSURL URLWithString:@"http://www.secondprizm.com"]];
}