|
Doh004 posted:Perhaps that wasn't the best example ever. I guess I'm more curious to people's thoughts as to when enums should own responsibility of more than just their values. I'm struggling to come up with a convincing reason for the enum to have anything unrelated to its value. You can certainly have methods, computed properties, and so on, but I reckon they shouldn't involve much beyond the enum itself.
|
# ¿ May 29, 2015 00:34 |
|
|
# ¿ May 14, 2024 16:46 |
|
rjmccall posted:In this matter, I counsel patience. So excited. Have an awesome week.
|
# ¿ Jun 7, 2015 15:52 |
|
Doctor w-rw-rw- posted:Any chance that we can get swift code formatting support (a la clang-format)? I like being sloppy with my spaces, and lament its loss. In the meantime, there's SwiftLint, which doesn't do quite what you want but might give you some ideas if you get antsy.
|
# ¿ Jun 14, 2015 15:19 |
|
lord funk posted:Is it possible to store an array of class types? I have a group of classes that conform to a protocol which declares a static variable. Does let classes = [Foo.self, Bar.self] work? Doh004 posted:The more Swift we do, the less and less I'm willing to allow force unwraps to make it through code reviews. Is that completely misguided or is having lots of if lets what we do with Swift? Use them where crashing is reasonable behaviour. The file manager can't give you back your App Support path? You're hosed, crash it. You're pretty sure this array is nonempty but you can't be arsed to check? Try harder.
|
# ¿ Jun 16, 2015 15:19 |
|
Could use a struct.
|
# ¿ Jun 25, 2015 12:30 |
|
I suppose. Though a struct also lets you choose not to forward certain operations at your option. Dividing grams by grams may not make sense.
|
# ¿ Jun 25, 2015 12:56 |
|
Kallikrates posted:It's simplistic to say that you should never check if error is set to see if an error occurred. Good thing that's not the rule! The rule is "check the return value to see if an error occurred". Which is exactly as simple as it should be.
|
# ¿ Jul 2, 2015 15:02 |
|
xctool links against private Xcode frameworks, so I believe you'll want to rebuild/reinstall it whenever you xcode-select to some other version (and whenever you update Xcode). Maybe you can build separate copies as xctool6 and xctool7?
|
# ¿ Aug 19, 2015 01:46 |
|
Sooo cool! It's not that I didn't believe it would happen, but you just never know until it does. Congrats!
|
# ¿ Dec 3, 2015 17:59 |
|
Toady posted:As an opposing view, I'm burned out from the verbosity of Objective-C APIs and find it a real chore at times. Agreed. I'm happy not to feel the need to add a bunch of newlines in my method calls and line up the precious colons. Most Swift calls fit nicely on one line.
|
# ¿ Jan 31, 2016 04:23 |
|
That's when I add print() everywhere and recompile.
|
# ¿ Feb 21, 2016 20:07 |
|
A struct with var properties is still immutable.
|
# ¿ Feb 27, 2016 01:27 |
|
I only noticed today that the Swift Package Manager will generate you an Xcode project (as of a month and a half ago, I'm slow ok). You do that, flip your toolchain in Xcode preferences, and now you've got a real nice autocompleting environment for your Swift development needs. Definitely curious to see how Xcode 8 interacts with SPM. I'm tentatively excited to never use CocoaPods again.
|
# ¿ Apr 28, 2016 00:35 |
|
Doesn't solve that directly (though I'm seeing much snappier autocomplete with the trunk toolset). What it solves for me is good editor support for making things using the Swift Package Manager. edit: previously it was just editing like a single file in Xcode outside of a project, you don't get any compiler-assisted autocomplete or inline errors.
|
# ¿ Apr 28, 2016 02:44 |
|
The Advanced Swift book from the-decreasingly-well-named objc.io sounds like it might be a good fit. Spends most of its time talking about things Swift does (well) that objc doesn't (do as well). It's up-to-date for Swift 2.2, which is nice because there's a lot of excited material out there talking about code that doesn't compile anymore. Then it spends the rest of its time talking about things that are trivially not a problem in objc. You can probably skip those parts if you're not interested.
|
# ¿ Apr 29, 2016 02:34 |
|
Doctor w-rw-rw- posted:While that would indeed be glorious, React's popularity makes a syntax for inline component hierarchy definition a prerequisite for that. I think Apple (and others) underestimate the value in doing so. Maybe I'm misunderstanding what "a syntax for inline component hierarchy definition" is, but why don't Swift enums fit that bill? Why do you think people are underestimating the value of a syntax for inline component hierarchy definition?
|
# ¿ May 13, 2016 01:23 |
|
Doctor w-rw-rw- posted:Am I missing something? Enums can't be subclassed, and enums can't have arrays for default values. Not to mention that components can still be kind of stateful in some corner cases. I can't envision it being cleaner than Objective-C (with the C++ part for cleaner inline syntax). No, they can't be subclassed, but I figured one could deal with that using protocols. I don't know ComponentKit beyond page one of the tutorial though so I'm probably wrong about its suitability in Swift. And sure, without the syntax dickery possible in newer C++ it probably wouldn't be cleaner in Swift, but I bet you could get close. quote:It sounds to me like Apple teams (aside from devtools/compilers) struggle to push software meaningfully forward in a way other than line items in a slide on Apple's next hardware unveiling. Even if an engineer wanted to support a dramatically different but proven model for building UIs, they'd face a lot of institutional pressure against it. Some ex-Apple engineers I've talked to have expressed similar disappointments, though to be fair, them being ex-Apple, the likelihood of that is higher. Neither JS nor PHP have XML literals though? I'm not really sure what your point is here, with that or with the grousing about Apple dev teams' management. What part of ComponentKit, or React, or whatever is fundamentally untenable in Swift today?
|
# ¿ May 13, 2016 13:15 |
|
smackfu posted:It's interesting to see all this heated Swift debate coming up now. Wonder what triggered it? Seems to go in waves. Often a Respected Member of the Community will write a variously dismissive thing that sets everyone off.
|
# ¿ May 28, 2016 02:38 |
|
HaB posted:So if I am creating an extension on say - String. What magic must I perform to keep that in its own file? I don't understand. The usual access modifiers (private, internal, public) should do it for you?
|
# ¿ Jun 11, 2016 18:47 |
|
TheReverend posted:Am I doing something dumb? Why is String.hash returning Int? Shouldn't it be UInt? Pretty sure that's because Swift imports NSUInteger as Int.
|
# ¿ Jun 14, 2016 19:38 |
|
Start interviewing now, learn up on whatever you encounter.
|
# ¿ Jun 17, 2016 03:02 |
|
Guess: trying to run objc in a swift context. Try sticking some -l objc++ after your command (e.g. expr -l objc++).
|
# ¿ Jul 21, 2016 03:39 |
|
open as the next access modifier after public? Wish I'd thought of that. So simple. So obvious. Congrats on exiting your own lil personal hell rjmccall
|
# ¿ Jul 28, 2016 02:16 |
|
I will have to remember that! I have noticed the SourceKit service tends to poo poo a brick when I start typing a lazy property initializer. I seem to bounce between "hiding all that setup inside the lazy property block is nice and convenient I should do this as much as possible" and "these plain old unadorned properties sure are tidy I should do this as much as possible". That might make it easier.
|
# ¿ Nov 1, 2016 00:04 |
|
eschaton posted:In case you missed it, Chris is a guest on the Accidental Tech Podcast and he talks about all sorts of stuff. This is great stuff. If you normally don't care for the hosts, listen anyway, it's like two hours of good questions and thoughtful answers.
|
# ¿ Jan 19, 2017 06:09 |
|
If anything included directly or indirectly in your bridging header pulls in a deprecation attribute you'll see exactly that issue. Any external libraries in our bridging header that in turn include AddressBook?
|
# ¿ Jan 24, 2017 18:10 |
|
It's a textbook example of the bike shed problem. I hadn't considered the "promotes bad programmer tendencies" aspect before. As someone who dgaf I that argument persuasive. And yeah, the migrator making everything fileprivate was an unforced error.
|
# ¿ Feb 19, 2017 01:41 |
|
Why can't I do this?Swift code:
code:
I feel like this must have come up on swift-evolution or in JIRA but I cannot find anything. It is kinda hard to search for because as soon as you put "optional" and "protocol" in a sentence you get optional protocol methods which is a different thing entirely.
|
# ¿ Feb 28, 2017 21:02 |
|
Cool, I'll open a ticket.
|
# ¿ Feb 28, 2017 23:51 |
|
Everything I can think of is on the roadmap with the possible exception of iOS support, which might not be an explicit goal but certainly seems to be am implicit goal.
|
# ¿ Jun 15, 2017 03:17 |
|
Doh004 posted:Uhh, why? I just meant I don't remember seeing anyone say "SPM will for sure support iOS and it'll happen on this date". But I do remember seeing more broad "we want to support all platforms where Swift officially runs" statements.
|
# ¿ Jun 15, 2017 16:36 |
|
Haven't tried it butSwift code:
|
# ¿ Jul 5, 2017 22:38 |
|
|
# ¿ May 14, 2024 16:46 |
|
TheReverend posted:Yeah, all this optional stuff is making it difficult. Coming from objc isn’t really the problem if the properties are helpfully modelled and annotated. It’s quite possible that juggling optional arrays makes flatMap too painful. Partly this is due to both Array.flatMap and Optional.flatMap existing, which can confuse you the programmer and occasionally the compiler too. There’s no shame in good ol' for loops if that’s the clearest way to model your problem. I like map and flatMap but it’s just one tool of many.
|
# ¿ Jul 6, 2017 00:19 |