iPhoneアプリケーションがクラッシュしてエラーが表示されます:
- [__NSCFDictionary stringByReplacingOccurrencesOfString:withString:]: unrecognized selector sent to instance 0x99f60b0
これが私のコードNSString*strDataです。AppDelegate * delegate =(AppDelegate *)[[UIApplicationsharedApplication]デリゲート]; if(delegate.respondInsightIndex){strData = [insights objectAtIndex:index]; } else {strData = [insights 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"]];
}