Ios 错误';类方法,以及目标c中对象的属性
我正在尝试简单地更新我公司在我上班之前创建的应用程序上的一些文本。该应用程序是一个原生iOS应用程序,我不熟悉objective C,因此我不确定如何搜索这些解决方案 我有以下代码:Ios 错误';类方法,以及目标c中对象的属性,ios,objective-c,Ios,Objective C,我正在尝试简单地更新我公司在我上班之前创建的应用程序上的一些文本。该应用程序是一个原生iOS应用程序,我不熟悉objective C,因此我不确定如何搜索这些解决方案 我有以下代码: - (IBAction)PlayFirstVideo:(id)sender { // allocate a reachability object Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"]; //
- (IBAction)PlayFirstVideo:(id)sender {
// allocate a reachability object
Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"];
// set the blocks
reach.reachableBlock = ^(Reachability*reach)
{
dispatch_async(dispatch_get_main_queue(), ^{
NSString *url = @"http://domainname.com/tvxcode/tomatobasilsequence/tomatobasil_all.m3u8";
videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:url]];
[self.view addSubview:videoPlayer.view];
videoPlayer.view.frame = CGRectMake(359, 0, 665, 375);
[videoPlayer play];
});
};
reach.unreachableBlock = ^(Reachability*reach)
{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *noConnection = [[UIAlertView alloc] initWithTitle:@"Connection Required"
message:@"An internet connection is required to view videos."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[noConnection show];
});
};
// start the notifier which will cause the reachability object to retain itself!
[reach startNotifier];
}
这会产生三个错误:
- 选择器“reachabilityWithHostname:”没有已知的类方法
- 在“可达性*”类型的对象上找不到属性“可达块”
- 在“可达性*”类型的对象上未找到属性“unreachableBlock”
我真正的问题显然是如何解决这个问题,但我甚至不确定这些是否是自定义类。它们似乎与以前开发人员的名称样式和习惯不匹配,因此如果是这样的话,这是因为我更新了xCode吗?可访问性类来自一个Apple示例项目
对您的错误最可能的解释是,该文件顶部没有“Reachability.h”的导入。您可能只得到了一个转发声明。上有一个单独的可达性项目,它似乎就是您正在使用的,与苹果版本不同。这两个可能是冲突 其他项目(如sharekit)包括reachability.h和.m文件。您可以检查一下您的include中是否有冲突的版本,以及定义之间的差异。我有第一个答案 选择器“reachabilityWithHostname:”没有已知的类方法 在您的代码中,方法名称为 可访问性与主机name: 原始方法名称为 可访问性与主机Name
它是区分大小写的Hmm,我确实在文档顶部有#import“Reachability.h”。还有其他想法吗?我面临同样的问题!