iOS - 是否可以向服务器发送连续连接请求?

发布于 2024-12-28 19:31:24 字数 586 浏览 3 评论 0原文

我有一个应用程序代码,仅在应用程序打开时发送请求。但是,我需要连续访问服务器中的文件,该文件每秒都会更新。

-(void)viewDidLoad
{
    [super viewDidLoad];

    NSURL *myurl = [NSURL URLWithString:@"URL"];
    NSString *mystring = [NSString stringWithContentsOfURL:myurl encoding:NSASCIIStringEncoding error:nil];
    //myTextView.text = realtime;
    //NSLog(mystring);

    NSString *stripped1 = [mystring stringByReplacingOccurrencesOfString:@"\r" withString:@""];

    NSArray *rows = [stripped1 componentsSeparatedByString:@"\n"];
}

有没有办法可以继续检查我的服务器文件以加载数据?目前,当我打开应用程序时,我只能加载一次。但它是一个实时更新应用程序。 谢谢。

I have a app code that sends in request only when the app opens. However I need to have a continuos access to the file in the server which will be updated every second.

-(void)viewDidLoad
{
    [super viewDidLoad];

    NSURL *myurl = [NSURL URLWithString:@"URL"];
    NSString *mystring = [NSString stringWithContentsOfURL:myurl encoding:NSASCIIStringEncoding error:nil];
    //myTextView.text = realtime;
    //NSLog(mystring);

    NSString *stripped1 = [mystring stringByReplacingOccurrencesOfString:@"\r" withString:@""];

    NSArray *rows = [stripped1 componentsSeparatedByString:@"\n"];
}

Is there a way that I can keep checking on my server file to load the data? Currently I can load it only once when I open the application. But its a live update application.
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

合久必婚 2025-01-04 19:31:24

您可以使用苹果通知来通知用户新数据。

但我不确定这是否是你想要的。

You may use apple notification to notify the user new data.

But I'm not sure if this is what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文