Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Doctor w-rw-rw-
Jun 24, 2008
edit: disregard

(The first time I tried signing up, the listserv never sent me a confirmation email. This time it did)

Adbot
ADBOT LOVES YOU

Doctor w-rw-rw-
Jun 24, 2008
Your question sounds like an XY problem:
http://meta.stackexchange.com/a/66378

It's not necessarily a good idea to couple whatever custom view you're writing closely to the behavior of your ViewController. What are you really trying to do?

If you're sure you need that though, have the view controller set a weak property on the view to itself.

Doctor w-rw-rw-
Jun 24, 2008
IMO unit testing UI is generally way more effort than payoff. Unit test core logic. Integration test the UI.

Doctor w-rw-rw-
Jun 24, 2008

fleshweasel posted:

It seems like something went wrong if you can't import a compiled module written in swift 2 from swift 3. I'm sure there's something I don't know, but goddamn.

Incompatible ABI. Conscious decision, not something unintentional.

Doctor w-rw-rw-
Jun 24, 2008
Thanks for open-sourcing swift-stdlib-tool!

Doctor w-rw-rw-
Jun 24, 2008
Worth adding that, IIRC, background queues get to run before dispatch_main() is called, but the main thread does not, until libdispatch is entered via dispatch_main, CFRunLoopRun, or {UI,NS}ApplicationMain.

I think the pure libdispatch method is to use dispatch_main() and atexit() for cleanup, and call exit() with your exit code (correct me if I'm wrong).

Depending on your script, you can also make things a little nicer if you like by using dispatch sources to respond to signals, accept stdin input, or track file updates, and other cool stuff. You can make it so that cancelling a dispatch source triggers said call to exit(). An empty while loop can easily consume tons of unnecessary CPU cycles, so if it fits the use-case, you can have a pretty low overhead process by using the loop functions that already exist.

Doctor w-rw-rw-
Jun 24, 2008
Is there an elegant abstraction for me to wrap lines of code to check errors in debug mode that will be compiled out zero cost in release mode? Specifically I'm using a rather stateful API with a geterror function that returns an error code, and I want to wrap every call to that API with something that will check for and log errors in debug mode, but get compiled out.

I currently have something like this:
Swift code:
func debug(file: String = #file, line: Int = #line, column: Int = #column, function: String = #function, statement: () -> Void) {
  statement()
  ...
  (log stuff here)
}
but that doesn't cover that blocks that return, blocks that throw, or both, and I presume that the code gets bloated tremendously, along with the compiler's ability to reason about it..

Doctor w-rw-rw-
Jun 24, 2008
Why is it so hard to turn an array of strings into a char** in Swift? :/

Adbot
ADBOT LOVES YOU

Doctor w-rw-rw-
Jun 24, 2008
*crosses fingers* I hope he goes to Facebook.

  • Locked thread