This file contains 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 privateMOC = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType) | |
privateMOC.parent = context | |
privateMOC.performAndWait { | |
//do some coredata stuff, but dont carry on beyond this block, until the code | |
//in this block has finished executed (sync, not async) | |
saveContext(forContext: privateMOC) | |
} | |
//now save the main context with the changes from the private context | |
saveContext(forContext: context) |
This file contains 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 queue = OperationQueue() | |
queue.maxConcurrentOperationCount = 2 | |
let operation1 = BlockOperation(block: { | |
let a = 5+1000 | |
print(a) | |
}) | |
operation1.qualityOfService = .userInitiated | |
let operation2 = BlockOperation(block: { |
This file contains 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 Foundation | |
import CoreData | |
protocol CoreDataManagerProtocol: class { | |
func didCartItemAdded() -> () | |
} | |
class CoreDataManager { |
This file contains 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
class LiveNewsInteractor: PresentorToInteractorProtocol{ | |
var presenter: InteractorToPresenterProtocol? | |
func fetchLiveNews() { | |
Alamofire.request(Constants.URL).response { response in | |
if(response.response?.statusCode == 200){ | |
guard let data = response.data else { return } | |
do { | |
let decoder = JSONDecoder() |
This file contains 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 Foundation | |
struct BaseURL { | |
static let baseURL = "https://learnappmaking.com/" | |
} | |
struct AppAPI { |