WWDC 2006 2007 2008 2009 2010 2011 2012 2013 2014
public struct PartialForEach< | |
Data: RandomAccessCollection & MutableCollection, | |
ID: Hashable, | |
Content: View, | |
More: View | |
> where Data.Index == Int { | |
@Binding var data: Data | |
let idKeyPath: KeyPath<Data.Element, ID> | |
let maxItems: Int | |
let collapsible: Bool |
struct User: Equatable { | |
var firstName: String | |
var lastName: String | |
} | |
@main | |
struct MyApp: App { | |
@State var value = User(firstName: "", lastName: "") | |
@State var showEdit = false |
// Copyright (c) 2019–20 Adam Sharp and thoughtbot, inc. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: | |
// | |
// The above copyright notice and this permission notice shall be included in |
// Copyright (c) 2019–20 Adam Sharp and thoughtbot, inc. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: | |
// | |
// The above copyright notice and this permission notice shall be included in |
/* | |
====================================================== | |
THIS CODE IS FOR EDUCATIONAL PURPOSES ONLY. | |
I'M NOT RESPONSIBLE IF YOU SHIP THIS AND IT BLOWS UP IN YOUR FACE. | |
IF IT DOES AND YOU COMPLAIN TO ME I WILL LAUGH AT YOU. |
#!/bin/bash | |
| |
echo "You enter a dark dungeon. A sign in front of you says: Choose wisely or you'll probably die." | |
read -p 'staging or production: ' ENV | |
| |
if [ $ENV != "staging" ] && [ $ENV != "production" ] | |
then | |
echo "You go into the wrong hallway, a skeleton comes out and decapitates you. The End." | |
exit 1 | |
fi |
// Extend NSWorkspace and add a method to test if the volume is a network mount | |
@implementation NSWorkspace (Extras) | |
- (BOOL)checkForNetworkMountAtPath:(NSString*)path { | |
struct statfs stat; | |
int err = statfs([path fileSystemRepresentation], &stat); | |
if (err == 0) | |
{ | |
return !(stat.f_flags & MNT_LOCAL); | |
} | |
return NO; |
The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).
My take-aways are:
-
You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.
-
Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse