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
import errno | |
import shutil | |
def copy(src, dest): | |
try: | |
shutil.copytree(src, dest) | |
except OSError as e: | |
# If the error was caused because the source wasn't a directory | |
if e.errno == errno.ENOTDIR: | |
shutil.copy(src, dest) |
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
def pListModification(): | |
bundleName = "MY APP" | |
bundleIdentifier = "net.myapp" | |
plistNote ="app_directory/app_name/" + "/App/App-Info.plist" | |
plistNoteData = plistlib.readPlist(plistNote) | |
plistNoteData['CFBundleDisplayName'] = "New My App" |
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
def openNotesXcodeProject(): | |
print("My App XCODE OPENING") | |
pathToOpen = "/app_directory/app_name/"+ "App.xcworkspace" | |
openFile = "open " + "'" + pathToOpen + "'" | |
os.system(openFile) |
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
import UIKit | |
import PlaygroundSupport | |
//to run serial queue in playground always make the following true | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
let mainQueue = DispatchQueue.main | |
let globalQueue = DispatchQueue.global() | |
let serialQueue = DispatchQueue(label: "net.ithinkdiff.app") | |
let concurQueue = DispatchQueue(label: "net.ithinkdiff.app.concurr", attributes: .concurrent) |
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
import UIKit | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
let workingQueue = DispatchQueue(label: "net.ithinkdiff.app", attributes: .concurrent) | |
let globalQueue = DispatchQueue.global() | |
let defaultGroup = DispatchGroup() //create a new group | |
func multiplication(_ num: (Int, Int)) -> Int{ | |
sleep(1) //to make the method slower |
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
//Single BlockOperation | |
var result:Int? | |
let multiplication = BlockOperation{ | |
result = 5 * 10 | |
} | |
multiplication.start() | |
result | |
[/code] | |
Multiple operations using BlockOperation: |
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 pairOfNumbers = [(2, 3), (5, 10), (4, 5)] | |
class MultiplcationOp : Operation{ | |
var inputPair: [(Int, Int)]? | |
override func main() { | |
guard let inputPair = inputPair else { return } | |
for pair in inputPair{ | |
let result = pair.0 * pair.1 | |
print(result) |
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
import UIKit | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
let pairOfNumbers = [(2, 3), (5, 10), (4, 5)] | |
let operationQueue = OperationQueue() | |
//if set 1, it will be serial if commented it will be concurrent | |
operationQueue.maxConcurrentOperationCount = 1 |
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
enum SampleError: Error { | |
case sample1 | |
case sample2(message: String) | |
} |
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
func sampleThrowError() throws -> String { | |
throw SampleError.sample1 | |
return "" | |
} |