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
protocol EntityRequest { | |
var entityName: String { get } | |
var predicate: NSPredicate? { get } | |
} |
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
class StandingsNetworkRequest: StandingsEndpointRequest { | |
let tournamentId: Int32 | |
init(tournamentId: Int32){ | |
self.tournamentId = tournamentId | |
} | |
func url() -> String { | |
return "https://service-url/getStandings?tournamentId=\(tournamentId)" | |
} |
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
protocol StandingsEndpointRequest: RequestProtocol { | |
var tournamentId: Int32 { get } | |
} | |
extension StandingsEndpointRequest { | |
func parser(parseDelegate: ParseDelegate, parentContext: NSManagedObjectContext) | |
-> ParseOperation { | |
return StandingsParser(delegate: parseDelegate, parentContext: parentContext) | |
} | |
} |
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
class StandingsDatasource: ManagedDataSource { | |
let request: StandingsRequest | |
... | |
init(request: StandingsRequest, ...) { | |
self.request = request | |
... | |
} |
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
class StandingsDatasource: ManagedDataSource { | |
var request: StandingsRequest? | |
... | |
override func requestData() { | |
guard request = self.request else { | |
assertionFailure("Request is not initiated in StandingsDatasource") | |
return | |
} |
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
class StandingsRequest: RequestProtocol { | |
let tournamentId: Int32 | |
init(tournamentId: Int32){ | |
self.tournamentId = tournamentId | |
} | |
func url() -> String { | |
return "https://service-url/getStandings?tournamentId=\(tournamentId)" | |
} |
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
public class Standing: NSManagedObject { | |
@NSManaged public var tournamentId: Int32 | |
@NSManaged public var title: String | |
@NSManaged public var content: String | |
@NSManaged public var groupName: String | |
} | |
// MARK: - Preidcates | |
public extension Standing { | |
static func predicateWith(groupName: String?) -> NSPredicate? { |
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
class StandingsDatasource: ManagedDataSource { | |
let tournamentId: Int32 | |
let groupName: String? | |
let dataController: RequestDataConnectionController | |
init(tournamentId: Int32, | |
groupName: String?, | |
managedObjectContext: NSManagedObjectContext, |
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
override func viewDidLayoutSubviews() { | |
super.viewDidLayoutSubviews() | |
self.contentView?.maskAndRoundCorners(corners: [.topRight, .topLeft], radius: 8) | |
} | |
extension UIView { | |
/// Masking and rounding the view corners | |
/// | |
/// NOTE: should be used in viewDidLayoutSubviews as it manipulates the layers |
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 XCTest | |
import CoreData | |
@testable import MyApp | |
class NewsTests: CoreDataBaseTest { | |
private let jsonFile = "news_today" | |
func testReadingJsonFiles() { | |
let dataDict = self.getJsonDictionaryFromFile(self.jsonFile) |