20 comments

[ 3.2 ms ] story [ 60.7 ms ] thread
And it starts again - web framework, 2048, flappy bird, http server, PySwift, JSwift, How I switched from Go to Swift, Swide: The Open Source swift IDE.. :)
This was actually part of something else I've been working on rather than attempt at deliberately reinventing the wheel. That said, I do think there's some benefit in rewriting existing Objective-C frameworks in Swift as Swift's interoperability with Objective-C can be difficult to deal with at times
Why is the code so verbose?

     let result = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, self.bridgeToObjectiveC(), charactersToLeaveUnescaped, charactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)) as String
Almost all of Apple's frameworks written in Objective-C and C are incredibly verbose. It's just an adopted style of the language and although it's often a little difficult to look at, it can be quite helpful sometimes
Swift should be less verbose
It is actually, but functions like the one mentioned above are bindings for Objective-C / C functions and share the same name as the function they bind to
While Swift is a new language, that method is calling into very old framework code written in Objective-C. Which is very verbose.
That looks more like a C function call. If it was an Objective C message the named parameters would make it far more verbose (and readable).
(comment deleted)
Can the OP tell us anything about building their Twitter framework in Swift. Any gotchas or problems they came across building it? Is Swift ready for the primetime. Should I start switching all my apps to Swift ASAP? Otherwise I'm just starting at code in a language I can hardly read.
I'm rewriting one of my apps in Swift and I'm enjoying it a lot, but it's definitely a bumpy road. You're dealing with both a beta IDE and a beta language, and you have to get used to a myriad of errors, some of which are indecipherable (arcane things like issues iterating over an array or Optional behavior that doesn't mesh with documentation/templates). Still, Swift is a joy to program in compared to Objective-C (at least IMHO) and its giving me the chance to re-architect a very poorly planned v1.0, so that alone is worth the trouble.

I think it's a good idea if you're very interested in learning Swift, but not really worth doing for its own sake.

Most of problems I encountered while writing this came from Swift's interoperability with Objective-C. It can often be difficult to work with and takes a while to get used to. I actually think it would be worth developers considering porting their existing Objective-C libraries to Swift for this reason alone. That said, I don't think developers should start porting their App Store apps yet. It still feels very much like it's in beta and some functionality hasn't been implemented (such as static class variables). Despite this though, I think Swift has a huge amount of potential, and once things really kick off with it, we'll probably be seeing a lot more developers writing apps in Swift than in Objective-C. The language really has a lot to offer over Objective-C in my opinion

PS: hi kevin

I thought I was imagining the static class problem...the documentation, while well-written, leaves much to be desired, especially for the above-mentioned. I've enjoyed writing in Swift so far but the playground crashes often. Xcode has not yet, so that has helped.
One question related to building framework on ios : does swift provide any benefit over objective c for creating frameworks ? I suppose it doesn't make any difference since those kind of issues are more related to the OS or the IDE but i was just wondering. Creating frameworks that you can easily distribute in both debug / release mode for both simulator/device has always been such a hassle ( and even more so when it contains resource bundles).
The processes for creating frameworks in Swift is pretty much the same as with Objective-C. That said Xcode 6 has made it much easier to handle distributing frameworks for different devices
Awesome - the usefulness of twitter combined with the cross platform approach of swift. A winning combo!
One gotcha is that Obj-C classes can't subclass Swift classes. Or at least that's what I got from the docs.

So writing frameworks designed to be subclassed means you're probably stuck in Obj-C for quite some years.