Accessing file system?

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

  1. Tanax macrumors 6502a

    Joined:
    Jun 15, 2011
    Location:
    Stockholm, Sweden
    #1
    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

    briloronmacrumo

    Joined:
    Jan 25, 2008
    Location:
    USA
    #2
    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/

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

    Joined:
    Aug 9, 2009
    #3
    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.
     

Share This Page