You must read the text file over the network (local) and display the text on the screen.

Where is it better to place the file - share it on the network or place it on an Apache server? How to open a file from the project folder (how to set the path) and where to put it there?

While something is pointing the way - but the program does not see the file.

Update

NSString* filePath = @"/192.168.1.210/projects/test.txt"; NSString *myText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; if(myText==nil) [self.textview setText:@"Hello world!!!!"]; else [self.textview setText:myText]; 

Update 2

 NSString* filePath = @"smb://192.168.1.189/Users/dieego/Desktop/share/test.txt"; NSError *error; NSString *ps = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error: &error]; if(ps==nil) [self.textview setText:[error localizedDescription]]; else [self.textview setText:ps]; 

This code prints to a textView.

"The operation couldnt be completed (Cocoa error 260)"

  • and how do you pass the link to the file? - Max Mikheyenko
  • try adding the protocol ' 192.168 .....' and it’s interesting to see if the error can clarify something. - Max Mikheyenko
  • Is there something in error? and I meant 'http' not 'smb' - Max Mikheyenko
  • changed to http - everything also. "The operation couldnt be completed (Cocoa error 260)" is in error - user3216530
  • NSFileReadNoSuchFileError - 260 is no file. I will try to reproduce in myself - Max Mikheyenko

1 answer 1

Try using NSUrl * filePathURL = [NSUrl urlWithString:filePath];

  • Use framing single quotes `to select part of the code. - AivanF.