Accessing file system?

Discussion in 'Mac Programming' started by Tanax, Sep 14, 2014.

  1. Tanax macrumors 6502a

    Jun 15, 2011
    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..
  2. briloronmacrumo macrumors 6502


    Jan 25, 2008
    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"

    Try typing this in to Google search: "accessing files using swift cocoa" yields some helpful results.
  3. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    There's this, on Apple's Swift Blog:

    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.

Share This Page