gpt4 book ai didi

ios - 类方法的错误,以及 objective-c 中对象的属性

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:13:52 25 4
gpt4 key购买 nike

我正在尝试简单地更新我公司之前创建的应用程序中的一些文本。该应用程序是原生 iOS 应用程序,我不熟悉 Objective-C ,所以我不确定如何搜索这些解决方案。

我有以下代码:

- (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:”没有已知的类方法
  • 在“Reachability *”类型的对象上找不到属性“reachableBlock”
  • 在“Reachability *”类型的对象上找不到属性“unreachableBlock”

我真正的问题显然是如何解决这个问题,但我什至不确定这些是否是自定义类。它们似乎不符合以前开发人员的名称样式和习惯,所以如果是这样的话,这是因为我更新了 xCode 的问题吗?

最佳答案

我有第一个答案

选择器“reachabilityWithHostname:”没有已知的类方法

在你的代码方法名称是reachabilityWithHostn名称:

原来的方法名是reachabilityWithHost名称名称

区分大小写

关于ios - 类方法的错误,以及 objective-c 中对象的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16658814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com