我的 iPhone 应用程序崩溃并显示错误:
- [__NSCFDictionary stringByReplacingOccurrencesOfString:withString:]: unrecognized selector sent to instance 0x99f60b0
这是我的代码 NSString *strData; AppDelegate *委托=(AppDelegate *)[[UIApplication共享应用]委托]; if (delegate.respondInsightIndex) { strData = [见解 objectAtIndex:index]; } else { strData = [insights lastObject];
}
NSString *strReplace = [NSString stringWithFormat:@"%@",[strData stringByReplacingOccurrencesOfString:@"%20" withString:@" "]];
Run Code Online (Sandbox Code Playgroud)
这是我的方法,崩溃再次发生
- (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"]];
Run Code Online (Sandbox Code Playgroud)
}
- stringByReplacingOccurrencesOfString因此,这意味着您正在尝试在实例上使用该方法,NSDictionary而该实例当然是行不通的。
该物体strData并不NSString像你想象的那样是一个物体。它实际上是 的一个对象NSDictionary。
| 归档时间: |
|
| 查看次数: |
856 次 |
| 最近记录: |