This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property (atomic, strong) NSString *exampleAtomicProperty; | |
@property (nonatomic, strong) NSString *exampleNonAtomicProperty; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline void reallySetProperty(id self, SEL _cmd, id newValue, | |
ptrdiff_t offset, bool atomic, bool copy, bool mutableCopy) | |
{ | |
id oldValue; | |
id *slot = (id*) ((char*)self + offset); | |
if (copy) { | |
newValue = [newValue copyWithZone:NULL]; | |
} else if (mutableCopy) { | |
newValue = [newValue mutableCopyWithZone:NULL]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DispatchQueue.global(qos: .utility).sync { | |
// Background Task | |
DispatchQueue.main.sync { | |
// App will crash | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let customSerialQueue = DispatchQueue(label: "com.yogevsitton.MyApp.myCustomSerialQueue") | |
customSerialQueue.sync { | |
// Synchronous code | |
customSerialQueue.sync { | |
// This code will never be executed and the app is now in deadlock | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DispatchQueue.global(qos: .background).async { | |
// Do some background work | |
DispatchQueue.main.async { | |
// Update the UI to indicate the work has been completed | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DispatchQueue.global(qos: .utility).async { | |
// Asynchronous code running on the low priority queue | |
} | |
DispatchQueue.main.async { | |
// Asynchronous code running on the main queue | |
} | |
DispatchQueue.global(qos: .userInitiated).sync { | |
// Synchronous code running on the high prioriy queue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let customSerialQueue = DispatchQueue(label: "com.yogevsitton.MyApp.myCustomSerialQueue") | |
customSerialQueue.async { | |
// Code | |
} | |
let customConcurrentQueue = DispatchQueue(label: "com.yogevsitton.MyApp.myCustomConcurrentQueue", attributes: .concurrent) | |
customConcurrentQueue.async { | |
// Code | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CustomStringConvertible { | |
var description : String { | |
var description: String = "" | |
if self is AnyObject { | |
description = "***** \(self.dynamicType) - <\(unsafeAddressOf((self as! AnyObject)))>***** \n" | |
} else { | |
description = "***** \(self.dynamicType) *****\n" | |
} | |
let selfMirror = Mirror(reflecting: self) | |
for child in selfMirror.children { |