开发者

Fetching a file from a server with an iphone app

开发者 https://www.devze.com 2023-03-06 19:08 出处:网络
How does one download or fetch a file using iOS? I want to fetch a plist file from a ser开发者_运维知识库ver and open it within the app.

How does one download or fetch a file using iOS?

I want to fetch a plist file from a ser开发者_运维知识库ver and open it within the app.

Does there need to be a php web client on the server or how would this be done, keeping security in mind to?


NSURL *address = [NSURL URLWithString:@"http://yourwebsite.com/file.plist"];
NSString *fileString = [NSString stringWithContentsOfURL:address];


with this You can fetch file content in a string.

NSURL *address = [NSURL URLWithString:@"http://yourwebsite.com/file.plist"];
    NSString *fileString = [NSString stringWithContentsOfURL:address encoding:NSUTF8StringEncoding error:nil];

after fetching you can display this content in UITextView.

[youtextview setText:fileString];
0

精彩评论

暂无评论...
验证码 换一张
取 消