次のようにヘッダーNSString *oldChat
ファイルに設定しました:
@interface CTFChatViewController : UIViewController {
NSString *oldChat;
}
- (void)updateChat;
@property (nonatomic, retain) NSString *oldChat;
@end
そして、私はそれを使用しました:
- (void)updateChat
{
NSString *chat = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://theshay.byethost7.com/chat.php"] encoding:NSUTF8StringEncoding error:nil];
if (![chat isEqual:oldChat])
{
[webView loadHTMLString:chat baseURL:nil];
oldChat = chat;
}
[self performSelectorInBackground:@selector(updateChat) withObject:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSString *chat = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://theshay.byethost7.com/chat.php"] encoding:NSUTF8StringEncoding error:nil];
oldChat = chat;
[webView loadHTMLString:chat baseURL:nil];
[self performSelectorInBackground:@selector(updateChat) withObject:nil];
}
アプリがエラーでクラッシュしif (![chat isEqual:oldChat])
ました。EXC_BAD_ACCESS
なぜクラッシュしたのですか?
(XCode 4.5.2、iPhone シミュレーター 6.0、ベース SDK 6.0)