Search code examples
iphoneobjective-cxcodensurlnsurlrequest

get access to a file of another PC through NSURL


I can access to my local file through NSURL by using:

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://localhost/Users/user/Desktop/lucky_numbers.json"]];  

But I need to get access of a file of another PC. I tried:

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://foyzulkarim:[email protected]/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]];

and

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://192.168.1.48/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]];

and

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://Foyzul-Karims-MacBook.local/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]];

But Error shows NSURLError domain code -1100

Please help me if anyone knows how to do this.


Solution

  • You can access to my local file through NSURL by using: NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://192.168.1.48/localhost/Volumes/foyzulkarim/Desktop/lucky_numbers.json"]];

    but, to do this you have to first connect with that PC manually.