Closed

Fix code to read in two text files in Swift 4, OSX, when one file name is selected.

I have the following code to read in two text files located in the same directory. It reads in the first file but then says I don't have the permission to read in the second throwing the following error: The file “[url removed, login to view]” couldn’t be opened because you don’t have permission to view it.

@IBAction func OpenDVAFile(_ sender: Any) {

let dialog = NSOpenPanel();

[url removed, login to view] = "Choose a .dva or .tsn file";

[url removed, login to view] = true;

[url removed, login to view] = false;

[url removed, login to view] = true;

[url removed, login to view] = true;

[url removed, login to view] = false;

[url removed, login to view] = ["dva", "tsn"];

if ([url removed, login to view]() == [url removed, login to view]) {

let result = [url removed, login to view] // Pathname of the file

if (result != nil) {

do {

// Remove the file extension

let baseFile = result?.deletingPathExtension()

// Open the TSN File

let tsnFileURL = baseFile?.appendingPathExtension("TSN")

let tsnFileString = try String( contentsOf: tsnFileURL!)

// Open the DVA File

let dvaFileURL = baseFile?.appendingPathExtension("DVA")

let dvaFileString = try String( contentsOf: dvaFileURL!)

}

catch {

print( [url removed, login to view] )

}

}

}

}

Skills: Mac OS, Objective C, Swift

See more: swift openpanel, ios application support directory, nsopenpanel example, ios get file path from documents directory, xcode nsopenpanel, nssavepanel swift, ios list files in documents directory, nsopenpanel, write code including text files html php, lotus script read text files, read text files, script read text files, write program java read text files randomly, perl read text files directory, read text files programming

About the Employer:
( 134 reviews ) Bonita Springs, United States

Project ID: #15632062

11 freelancers are bidding on average $31 for this job

covernal

Hi Sir I can do your project perfectly. I have rich experience in Mobile Development for 8 years. It is no problem for me. Relevant Skills and Experience Mobile Developer Proposed Milestones $25 USD - Further

$25 USD in 1 day
(18 Reviews)
6.5
YouSheng

Hi. How are you? Would you send me your source project please? I can check your source and find solution for your project. Thanks

$25 USD in 1 day
(12 Reviews)
5.2
$25 USD in 1 day
(8 Reviews)
4.0
Rjmaurya13

Hi, I have 5 years experience in iOS application development. I think i can help you and contribute to successfully build your application. Thanks. Relevant Skills and Experience I have 5 years experience in iOS ap More

$111 USD in 3 days
(3 Reviews)
3.9
$25 USD in 1 day
(3 Reviews)
3.7
jangjinmei728

Hi, There! I read your project description fully and checked uber-eats also. As dedicated iOS expert, I can do your project perfectly. Please modify below: if let tsnFileURL == baseFile?.appendingPathExtension("T More

$25 USD in 1 day
(6 Reviews)
3.2
anumothu

While I were checking your code instead of you are reading two different file, you just adding the path extension of same file. Either one case will fail. Second please check whether the file is not corrupted and able More

$20 USD in 1 day
(1 Review)
1.4
$25 USD in 1 day
(2 Reviews)
1.3
CodeDevBuilder

Hello, Did you check the permission of the file? I think it doesn't have proper read permission. I can fix it in 1 hr. Thanks Relevant Skills and Experience Swift, IOS app development Proposed Milestones $20 USD - Fi More

$20 USD in 1 day
(0 Reviews)
0.0
$11 USD in 1 day
(0 Reviews)
0.0
$25 USD in 1 day
(0 Reviews)
0.0