|
Axiem posted:Is Swift going to be supporting unit testing and the like? My workplace is thoroughly in the TDD camp (as am I), and having a language that really supports it would be fantastic. XCTest has basic support for Swift, including the new testing features announced today. If there's anything specific you'd like to see in the Swift testing experience we'd love to hear your thoughts on it.
|
# ¿ Jun 3, 2014 08:31 |
|
|
# ¿ Apr 29, 2024 04:03 |
|
rjmccall posted:Also I feel very slightly bad for randomly making fun of Ada. Only very slightly, though. I'm sure Ada can handle it. It has features for everything else.
|
# ¿ Jun 6, 2014 07:42 |
|
Ender.uNF posted:I am not advocating for exceptions, just dealing with the fact that they exist and will be thrown if you're using CoreData. Core Data really shouldn't be throwing an exception for anything that isn't programmer error; if it is, report it as a bug and send me the bug number for followup if you can.
|
# ¿ Jun 10, 2014 01:09 |
|
Doctor w-rw-rw- posted:If programmer error will happen, then it follows that exceptions will happen. I think it was implicit in his statement that if you're using Core Data, you're probably going to misuse it at some point and trigger an exception. I mean programmer error in the Cocoa sense; Cocoa exceptions aren't meant to be caught by an app and recovered from, they're meant to be caught by a debugger and prevented. In other words, "Core Data throws this exception I can't catch in Swift and there's nothing my code can do to prevent it" is properly solved by fixing Core Data not to throw an exception, rather than by letting your app continue with potentially corrupt state. Of course, if it's because of something an app did (like trying to fire a fault for a deleted object) the solution is to not get into that situation in the first place.
|
# ¿ Jun 10, 2014 02:11 |
|
Ender.uNF posted:edit: Anyone have success creating a framework and using unit tests written in Swift? I haven't done anything special whatsoever and my first attempt to run a test fails: The issue with this is that the Swift standard library isn't copied into the framework or the test bundle like it is for apps. You may be able to manually copy them into your test bundle so they're available when tests are run.
|
# ¿ Jun 12, 2014 02:06 |
|
ljw1004 posted:I'm struggling to make sense of named parameters. The online docs (and also the book, page 208) give this example code: Did you add this as a free function or as a method within a class? Free functions omit all parameter names by default, while methods within a class omit only the first parameter name. This is effectively like ObjC where a free function is just a C function, and a method in a class always has its name interspersed with the parameters.
|
# ¿ Jun 18, 2014 01:57 |
|
Dessert Rose posted:I keep banging my head into this Xcode bug where suddenly it will decide that my target might include its own product for every project I build. Even ones which previously built fine. Do you have something like your app's Info.plist also included in a Copy Bundle Resources build phase? That's often the culprit, typically the result of clicking the "please make this a member of my target" checkbox.
|
# ¿ Jun 19, 2014 19:55 |
|
Ender.uNF posted:And here is my SwiftNonStandardLibrary, featuring the missing readln(), extensions to SequenceOf<T>, exception handling, and some other goodies. Where's the code?
|
# ¿ Jun 26, 2014 05:30 |
|
Choadmaster posted:2) I know this bug is already filed, and the Swift team does not use dupes as a priority hint (understandable at this stage, as they presumably have a detailed roadmap for what needs to be completed already). I think that was referring to filing intentional duplicates to try to inflate priority, like "this bug is a duplicate of 12345, here's some text copied and pasted from a web site, I vote for this feature too!" If you are yourself running into a bug or other difficulty, you should always file it, and not worry about whether what you're filing is a dup of something else. (Only don't if you know your exact issue is already known and you've been asked not to—like, say, for access control in Swift.) Also, don't get caught up spending hours putting together a bug report, a couple sentences is fine if that's all you actually need to specifically describe the issue. If an engineering team needs more detail they'll ask. And push back if a bug comes back to you as fixed but from your perspective it's not. Finally, if you would like to see a feature/enhancement/change, you should also always file it yourself, and explain your needs clearly; they may not be addressed the way you requested, but they will be taken into account. (This is the reason "why" matters, not just "what.") An example of that from early OS X history was when some developers asked for the Enterprise Objects Framework to be brought forward; what they got was Core Data instead, as a model-level persistence framework for Cocoa.
|
# ¿ Jul 6, 2014 09:25 |
|
PleasureKevin posted:two things I could do in PHP that I guess I can't in swift? Correct, you can't omit braces, and this is a feature.
|
# ¿ Sep 3, 2014 18:01 |
|
Doh004 posted:I do iOS development for my job and I figured I should start learning how to use Swift, so I made TicTacToe. If anyone is bored could you please give me some pointers? I definitely found myself doing a lot of stuff incorrectly because I'm so used to Obj-C so I know I didn't do things in the proper "Swift" way (if that even exists?). Where are your tests? You should follow similar naming conventions to Objective-C with Swift, i.e. start properties and method names with a lower-case letter, make the name of a method read as a sentence, etc. For example, this: code:
should be more like this: code:
similar to how it would be in Objective-C. The separate model classes should also be in separate files, rather than all in one, for stylistic reasons. More practically they have methods that should really be properties, even computed properties like Player.displayName (for which I did like your use of interpolation, that's what I'd have done too). Also, the type for something like that can be just String, not String!, since you probably don't need to introduce an implicitly unwrapped optional for something like that. eschaton fucked around with this message at 05:09 on Sep 22, 2014 |
# ¿ Sep 22, 2014 04:59 |
|
fleshweasel posted:They implemented monads with the stupid operators because they thought it was too easy to tell what was going on. They should've added a native concept of combining diacritics to the language to represent the functional concept of composition. e: good luck distinguishing ± from + combined with an underbar diacritic!
|
# ¿ Feb 17, 2015 06:36 |
|
Ender.uNF posted:swiftc is written in C++... is there any reason that it doesn't catch exceptions and bail on processing a section of code (or a file) if it blows up? I think here you're conflating two different kinds of exceptions: language-level exceptions, and OS/system-level exceptions (traps, signals, whatever you'd like to call them). You can use signal() handlers and Mach exception handlers to try to capture OS-level exceptions, but your recovery options are limited except for very specialized software (like debuggers). Language-level exceptions tend to be designed for recoverability, though in practice most such exceptions should also wind up aborting the process because most software isn't itself designed for recovery.
|
# ¿ Apr 25, 2015 22:43 |
|
Axiem posted:Forgive my ignorance, but what does putting "import Foundation" or "import UIKit" at the top of a given Swift file inside a project actually do? I understand that in say, C, you provide header files in #import statements in order to let the linker do its job, but that was at a per-file level, not a per-module level. Header files in C-family languages aren't for the linker, they're for the compiler: In order to use functions or variables the compiler needs to see declarations for them, so it knows how to generate code to access them. This is done via direct text inclusion, which has its pluses and minuses. And it's the generated code (along with a list of libraries to look in for external definitions) that gets fed to the linker, not the headers. With Swift you can effectively treat module imports as the same sort of thing, just fancier. The compiler is basically doing the equivalent of precompiled prefix headers for you behind the scenes, because it doesn't have to worry about the language semantics specifying that literal text inclusion happens. (This also applies to @import in Objective-C.) quote:Following up on that, is there any compelling reason not to be able to say "just consider every file in this project to `import Foundation`"? It just seems odd to me that for Foundation, UIKit, or even any module that touches much of my code, I have to clearly define that I'm importing it. It helps the modularity of your code to be explicit about what it's using. As an example, if a class doesn't truly depend on anything from UIKit, it shouldn't import UIKit, and that means it'll be portable to OS X too. As an example, a couple years back I experimentally extracted an Awful.framework from Awful.app that would work on OS X. 99% of it didn't need UIKit and came right over, so it should have all just imported Foundation. (The only thing that didn't was something that triggered the network activity indicator, which was easily just abstracted behind a delegate.) In general, you'll find that lots of oldschool NeXT developers treat development as an exercise in putting together a bunch of frameworks that then get composed into one or more apps. Part of doing this is clearly defining the boundaries between the different parts of your app, which includes considering their dependencies.
|
# ¿ May 20, 2015 07:24 |
|
fleshweasel posted:
You shouldn't be checking errorPtr here, as with everything that deals with NSError you'll only get one back if the init fails and that's what you need to check for in Swift pre-2.0 or ObjC. (I can't tell you how many times I've seen [managedObjectContext save:&error]; if (error) { ... }, whoever told people they should do that is wrong wrong wrong.)
|
# ¿ Jul 2, 2015 09:17 |
|
Kallikrates posted:Okay I wrote that before coffee, I've run across methods that accept an error pointer, and return void. Or maybe I am mis remembering but I remember hitting something from some big Framework that was essentially: -(void)foo:(NSError **)error; None that I’ve seen in the Cocoa APIs are like that. It wouldn’t surprise me though if there were some developers who misunderstood the conventions and made frameworks like that. There are places in Cocoa where an error itself is passed as a parameter, and nil is used to indicate “no error.” But that's different then checking whether an error out-parameter was set.
|
# ¿ Jul 2, 2015 22:37 |
|
Gul Banana posted:tbh it's just kind of hard to take the 'catastrophe' pov seriously having spent years programming in each of cocoa, java and .net. they're directly comparable stacks Remember that Java's core libraries and even language features were based in significant part on the original NeXT AppKit design by Bill Parkhurst, the NeXT/Sun OpenStep API effort, and Objective-C. Then IFC (which was the basis for the Java 2 work) was specifically designed to mimic the NeXT APIs as well. And then Microsoft's Anders Heljsberg based C# and .NET on Java 1.x, while a certain Bill Parkhurst was one of the people behind the Visual Studio IDE. And the design of the original AppKit is traceable to MacApp, which is in turn traceable to the Lisa Application ToolKit. Both of which were implemented in Object Pascal, which Apple had hired Niklaus Wirth to help design, and which Borland and a certain Anders Heljsberg continued to promote and enhance long after Apple had switched to C++. There are very good historical reasons the frameworks and languages all feel similar. They're related kind of like English, Dutch, and German. There are other languages and frameworks out there that are a bit more different, and not just "research" ones either. (Though many have been consigned to the dustbin of history…)
|
# ¿ Feb 4, 2016 07:01 |
|
If you want to see what NeXT AppKit development was like pre-OpenStep, someone has an online collection of the Nextstep 3.3 documentation which includes such APIs as -[View drawSelf::] and -[View display:::]. Yes, that's two and three colons, respectively.
|
# ¿ Feb 4, 2016 07:07 |
|
emoji posted:Whatever it is, Xcode crashes very hard at the moment I attempt to package.loadlib using the raw symbol, tho not reliably. That's LLDB being killed because it's trying to read memory it's not allowed to for code signing reasons, or something along those lines. Please file a bug.
|
# ¿ May 11, 2016 17:10 |
|
PT6A posted:I mean, what fills up the students' time if they aren't teaching algorithm analysis and design in CS? I'd be hard pressed to come up with 50-60 credits of CS-relevant material without touching on those subjects. These type of degree programs often feature classes in various technologies instead. So you get classes on Java, .NET, C++, HTML and CSS "programming," game development, "apps," and so on. An IT degree at a good school is more of a CS degree than the above, but the above is what some schools offer as one. And neither is likely to know the joy of a real 18-unit Operating Systems class…
|
# ¿ Jul 23, 2016 12:19 |
|
Siguy posted:That pipermail interface is barely an interface. I feel like the Swift guys are intentionally clinging to the mailing list as a method of weeding out contributors. If you want to participate, you have to put up with a pretty arcane communication system. There's nothing arcane about using mailing lists for high volume discussion. They work extremely well for it and have for decades. Web forums are seriously poo poo, second in shiftiness only to web "chat" systems. If you want a fuller-featured archive interface for a list you can always build one, grab the mbox files for the archives, and put it up. quote:As a lurker curious about the language but not dedicated enough to read through a daily email log, I mostly get by with Erica Sadun's recaps. What does "a daily email log" even mean, a digest subscription? Just subscribe to the list and have your mail client (or server) filter it into a folder, then read it when you have time. Done. quote:If I want to find an actual post, the only not totally lovely solution I've found is to use Gmane's still operational NNTP server and browse with a newsreader: nntps://news.gmane.org/ You have discovered one of the other ways to deal with online discussion better than a web site. Web sites are fine for presenting archival information, for interaction that's why we have—and have had—apps.
|
# ¿ Aug 1, 2016 02:52 |
|
At least it's not a web forum.
|
# ¿ Oct 31, 2016 04:43 |
|
In case you missed it, Chris is a guest on the Accidental Tech Podcast and he talks about all sorts of stuff.
|
# ¿ Jan 19, 2017 03:15 |
|
While I'm a very strident advocate of files as primary source artifacts (for tool generality), imbuing the files themselves with meaning rather than their pure content seems like the wrong direction to go.
|
# ¿ Feb 19, 2017 23:12 |
|
Huckleduck posted:Quick question about using Swift as a script. I made an XCode project file with the Swift Package Manager. The purpose of the script is to contact a server and download some files, then write those files to disk. This is an async operation, but scripts end whenever they let go of the main thread. I've tried three things, one of which worked. For a classic command line tool with a main run loop, you'd run it repeatedly until the work is done, which would likely be signaled by a variable being set (in a thread-safe manner) by whatever the worker is, and then stopping the main run loop. The main run loop would check the variable (also in a thread-safe manner, of course) and then when it's set decide to stop running. Note that you can't rely on a run loop to stop on its own; the frameworks can add their own sources too, after all. I strongly suspect that whatever mechanism you used to do the download relied on having the main run loop turning, in which case the above sounds like what you should do too. Your #3 is very close to it, you just need to set the Boolean safely, check it safely, actually run the main run loop, and explicitly stop the main run loop after setting the Boolean. This should all also be easy to encapsulate.
|
# ¿ Apr 10, 2017 09:49 |
|
Kallikrates posted:Playgrounds haven't had inline errors for me for several releases. The code/run/output cycle isn't any faster these days than running an app/tests. Maybe I need to nuke my Xcode. Reinstalling Xcode is virtually never going to help anything. (Same with reinstalling the operating system.) Why is it even on peoples' list of things to try? You'd be better off trying the same thing under a brand new user account, in case there's some cached state interfering.
|
# ¿ Apr 13, 2017 19:22 |
|
|
# ¿ Apr 29, 2024 04:03 |
|
That's more of a UIKit framework question than a Swift language or tooling question, you might get more assistance in the Apple platform thread.
|
# ¿ Jun 18, 2017 06:40 |