Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Tanax

macrumors 65816
Original poster
Jun 15, 2011
1,040
416
Stockholm, Sweden
Where can I find information about accessing files and general file system API calls with Swift? I've tried searching but can't come up with anything..
 
Where can I find information about accessing files and general file system API calls with Swift?

When in doubt, RTM. There are several videos that can be downloaded freely from Apple's web site. My first reaction is use the Foundation classes( all the obvious stuff and more like writeToFile: writeToURL: for NSArrays and NSDictionaries ). Apple posted a pdf and web page titled "Using Swift with Cocoa and Objective-C" https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/

I've tried searching but can't come up with anything..
Try typing this in to Google search: "accessing files using swift cocoa" yields some helpful results.
 
There's this, on Apple's Swift Blog:
https://developer.apple.com/swift/blog/?id=6

Find libc on that page, and see examples of puts(), open(), etc. The type returned from open() is an int (file descriptor), and doesn't seem to cause any problems.

No examples of stdio are given in that article because that would involve non-object (unsafe) pointers. Googling for swift read file shows an example using NSFileHandle on StackOverflow.

Frankly, it seems pretty easy to find this stuff using fairly obvious search terms. Without seeing what search terms you used, it's impossible to comment on why you didn't find anything.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.