[swift-users] Newbie Question
jens at mooseyard.com
Tue Jan 5 11:09:39 CST 2016
> On Jan 4, 2016, at 9:07 AM, Sherri McGurnaghan via swift-users <swift-users at swift.org> wrote:
> I am trying to do something super simple using Swift - we are changing our infrastructure and the new environment requires me to work with Swift. Needless to say, I am a complete newbie and a bit lost on where to go first / start.
Unfortunately this isn’t the sort of thing that’s super simple with Swift right now, at least not on Linux. Swift doesn’t have a mature standard library yet for tasks like I/O, because on Apple platforms it’s been able to use the underlying Cocoa frameworks. There’s a project to create a new cross-platform standard library, but it’s in the early stages.
It’s definitely possible to call directly into C standard library functions like fopen and fwrite, but it requires knowledge of how C bridging works, and involves using special types like UnsafePointer. (There was a thread here a few weeks ago about how to do file I/O, if you want to search for it.)
Six months from now, doing some file copying with Swift should be a no-brainer! But for now I’d avoid it as a newbie task. If you just want a project to learn the language itself, I’d suggest doing some “CS 101” type exercises like implementing binary trees or computing prime numbers. Apple’s Swift book has some interesting sample programs in it too.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-users