iOS - 是否可以向服务器发送连续连接请求?
我有一个应用程序代码,仅在应用程序打开时发送请求。但是,我需要连续访问服务器中的文件,该文件每秒都会更新。
-(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用苹果通知来通知用户新数据。
但我不确定这是否是你想要的。
You may use apple notification to notify the user new data.
But I'm not sure if this is what you want.