Integrates mogenerator to automatically generate Core Data subclasses
This commit is contained in:
parent
ce41b83c92
commit
578cf5eda2
@ -22,7 +22,7 @@ final class DatabaseManager: NSPersistentContainer
|
||||
private init()
|
||||
{
|
||||
guard
|
||||
let modelURL = Bundle(for: DatabaseManager.self).url(forResource: "Model", withExtension: "momd"),
|
||||
let modelURL = Bundle(for: DatabaseManager.self).url(forResource: "Delta", withExtension: "momd"),
|
||||
let managedObjectModel = NSManagedObjectModel(contentsOf: modelURL)
|
||||
else { fatalError("Core Data model cannot be found. Aborting.") }
|
||||
|
||||
|
||||
@ -7,51 +7,17 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import DeltaCore
|
||||
|
||||
extension Cheat
|
||||
{
|
||||
enum Attributes: String
|
||||
{
|
||||
case identifier
|
||||
case name
|
||||
case code
|
||||
case type
|
||||
case enabled
|
||||
case creationDate
|
||||
case modifiedDate
|
||||
|
||||
case game
|
||||
}
|
||||
}
|
||||
|
||||
@objc(Cheat)
|
||||
class Cheat: NSManagedObject, CheatProtocol
|
||||
{
|
||||
@NSManaged var name: String?
|
||||
@NSManaged var code: String
|
||||
@NSManaged var type: CheatType
|
||||
@NSManaged var modifiedDate: Date
|
||||
@NSManaged var enabled: Bool
|
||||
|
||||
@NSManaged fileprivate(set) var identifier: String
|
||||
@NSManaged fileprivate(set) var creationDate: Date
|
||||
|
||||
// Must be optional relationship to satisfy weird Core Data requirement
|
||||
// https://forums.developer.apple.com/thread/20535
|
||||
@NSManaged var game: Game!
|
||||
}
|
||||
|
||||
extension Cheat
|
||||
{
|
||||
public class Cheat: _Cheat, CheatProtocol
|
||||
{
|
||||
@NSManaged private var primitiveIdentifier: String
|
||||
@NSManaged private var primitiveCreationDate: Date
|
||||
@NSManaged private var primitiveModifiedDate: Date
|
||||
@NSManaged private var primitiveType: NSNumber
|
||||
|
||||
override func awakeFromInsert()
|
||||
public override func awakeFromInsert()
|
||||
{
|
||||
super.awakeFromInsert()
|
||||
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="11185.3" systemVersion="15F34" minimumToolsVersion="Xcode 7.0" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="1.0">
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="11232" systemVersion="16A320" minimumToolsVersion="Xcode 7.0" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="1.0">
|
||||
<entity name="Cheat" representedClassName="Cheat" syncable="YES">
|
||||
<attribute name="code" attributeType="String" syncable="YES"/>
|
||||
<attribute name="creationDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="enabled" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="isEnabled" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="modifiedDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="name" attributeType="String" syncable="YES"/>
|
||||
<attribute name="type" attributeType="String" syncable="YES"/>
|
||||
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<attribute name="type" attributeType="Transformable" syncable="YES">
|
||||
<userInfo>
|
||||
<entry key="attributeValueClassName" value="CheatType"/>
|
||||
</userInfo>
|
||||
</attribute>
|
||||
<relationship name="game" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Game" inverseName="cheats" inverseEntity="Game" syncable="YES"/>
|
||||
<uniquenessConstraints>
|
||||
<uniquenessConstraint>
|
||||
@ -18,7 +22,7 @@
|
||||
<entity name="Game" representedClassName="Game" syncable="YES">
|
||||
<attribute name="artworkURL" optional="YES" attributeType="Transformable" syncable="YES">
|
||||
<userInfo>
|
||||
<entry key="attributeValueClassName" value="NSURL"/>
|
||||
<entry key="attributeValueClassName" value="URL"/>
|
||||
</userInfo>
|
||||
</attribute>
|
||||
<attribute name="filename" attributeType="String" syncable="YES">
|
||||
@ -28,7 +32,11 @@
|
||||
</attribute>
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="name" attributeType="String" syncable="YES"/>
|
||||
<attribute name="type" attributeType="String" syncable="YES"/>
|
||||
<attribute name="type" attributeType="Transformable" syncable="YES">
|
||||
<userInfo>
|
||||
<entry key="attributeValueClassName" value="GameType"/>
|
||||
</userInfo>
|
||||
</attribute>
|
||||
<relationship name="cheats" toMany="YES" deletionRule="Cascade" destinationEntity="Cheat" inverseName="game" inverseEntity="Cheat" syncable="YES"/>
|
||||
<relationship name="gameCollections" toMany="YES" deletionRule="Nullify" destinationEntity="GameCollection" inverseName="games" inverseEntity="GameCollection" syncable="YES"/>
|
||||
<relationship name="previewSaveState" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="SaveState" inverseName="previewGame" inverseEntity="SaveState" syncable="YES"/>
|
||||
@ -59,7 +67,11 @@
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="modifiedDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<attribute name="type" attributeType="Integer 16" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="type" attributeType="Integer 16" defaultValueString="1" usesScalarValueType="NO" syncable="YES">
|
||||
<userInfo>
|
||||
<entry key="attributeValueScalarType" value="SaveStateType"/>
|
||||
</userInfo>
|
||||
</attribute>
|
||||
<relationship name="game" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Game" inverseName="saveStates" inverseEntity="Game" syncable="YES"/>
|
||||
<relationship name="previewGame" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Game" inverseName="previewSaveState" inverseEntity="Game" syncable="YES"/>
|
||||
<uniquenessConstraints>
|
||||
@ -7,43 +7,13 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import DeltaCore
|
||||
import SNESDeltaCore
|
||||
import GBADeltaCore
|
||||
|
||||
extension Game
|
||||
{
|
||||
enum Attributes: String
|
||||
{
|
||||
case artworkURL
|
||||
case filename
|
||||
case identifier
|
||||
case name
|
||||
case type
|
||||
|
||||
case gameCollections
|
||||
case saveStates
|
||||
case previewSaveState
|
||||
case cheats
|
||||
}
|
||||
}
|
||||
|
||||
@objc(Game)
|
||||
class Game: NSManagedObject, GameProtocol
|
||||
public class Game: _Game, GameProtocol
|
||||
{
|
||||
@NSManaged var artworkURL: URL?
|
||||
@NSManaged var filename: String
|
||||
@NSManaged var identifier: String
|
||||
@NSManaged var name: String
|
||||
@NSManaged var type: GameType
|
||||
|
||||
@NSManaged var gameCollections: Set<GameCollection>
|
||||
@NSManaged var previewSaveState: SaveState?
|
||||
@NSManaged var saveStates: Set<SaveState>
|
||||
|
||||
var fileURL: URL {
|
||||
public var fileURL: URL {
|
||||
var fileURL: URL!
|
||||
|
||||
self.managedObjectContext?.performAndWait {
|
||||
@ -53,7 +23,7 @@ class Game: NSManagedObject, GameProtocol
|
||||
return fileURL
|
||||
}
|
||||
|
||||
var preferredFileExtension: String {
|
||||
public var preferredFileExtension: String {
|
||||
switch self.type
|
||||
{
|
||||
case GameType.snes: return "smc"
|
||||
|
||||
@ -6,32 +6,15 @@
|
||||
// Copyright © 2015 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import DeltaCore
|
||||
import SNESDeltaCore
|
||||
import GBADeltaCore
|
||||
|
||||
extension GameCollection
|
||||
{
|
||||
enum Attributes: String
|
||||
{
|
||||
case identifier
|
||||
case index
|
||||
|
||||
case games
|
||||
}
|
||||
}
|
||||
|
||||
@objc(GameCollection)
|
||||
class GameCollection: NSManagedObject
|
||||
public class GameCollection: _GameCollection
|
||||
{
|
||||
@NSManaged private(set) var identifier: String
|
||||
@NSManaged private(set) var index: Int16
|
||||
|
||||
@NSManaged var games: Set<Game>
|
||||
|
||||
var name: String
|
||||
{
|
||||
let gameType = GameType(rawValue: self.identifier)
|
||||
@ -66,7 +49,7 @@ class GameCollection: NSManagedObject
|
||||
index = Int16(INT16_MAX)
|
||||
}
|
||||
|
||||
let predicate = NSPredicate(format: "%K == %@", GameCollection.Attributes.identifier.rawValue, identifier)
|
||||
let predicate = NSPredicate(format: "%K == %@", #keyPath(GameCollection.identifier), identifier)
|
||||
|
||||
var gameCollection = GameCollection.instancesWithPredicate(predicate, inManagedObjectContext: managedObjectContext, type: GameCollection.self).first
|
||||
if gameCollection == nil
|
||||
|
||||
@ -7,28 +7,10 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import DeltaCore
|
||||
|
||||
extension SaveState
|
||||
{
|
||||
enum Attributes: String
|
||||
{
|
||||
case filename
|
||||
case identifier
|
||||
case name
|
||||
case creationDate
|
||||
case modifiedDate
|
||||
case type
|
||||
case gameType
|
||||
|
||||
case game
|
||||
case previewGame
|
||||
}
|
||||
}
|
||||
|
||||
@objc enum SaveStateType: Int16
|
||||
@objc public enum SaveStateType: Int16
|
||||
{
|
||||
case auto
|
||||
case general
|
||||
@ -36,41 +18,42 @@ extension SaveState
|
||||
}
|
||||
|
||||
@objc(SaveState)
|
||||
class SaveState: NSManagedObject, SaveStateProtocol
|
||||
public class SaveState: _SaveState, SaveStateProtocol
|
||||
{
|
||||
@NSManaged var name: String?
|
||||
@NSManaged var creationDate: Date
|
||||
@NSManaged var modifiedDate: Date
|
||||
@NSManaged var type: SaveStateType
|
||||
|
||||
@NSManaged fileprivate(set) var filename: String
|
||||
@NSManaged fileprivate(set) var identifier: String
|
||||
|
||||
// Must be optional relationship to satisfy weird Core Data requirement
|
||||
// https://forums.developer.apple.com/thread/20535
|
||||
@NSManaged var game: Game!
|
||||
|
||||
@NSManaged var previewGame: Game?
|
||||
|
||||
var fileURL: URL {
|
||||
let fileURL = DatabaseManager.saveStatesDirectoryURLForGame(self.game).appendingPathComponent(self.filename)
|
||||
public var fileURL: URL {
|
||||
let fileURL = DatabaseManager.saveStatesDirectoryURLForGame(self.game!).appendingPathComponent(self.filename)
|
||||
return fileURL
|
||||
}
|
||||
|
||||
var imageFileURL: URL {
|
||||
public var imageFileURL: URL {
|
||||
let imageFilename = (self.filename as NSString).deletingPathExtension + ".png"
|
||||
let imageFileURL = DatabaseManager.saveStatesDirectoryURLForGame(self.game).appendingPathComponent(imageFilename)
|
||||
let imageFileURL = DatabaseManager.saveStatesDirectoryURLForGame(self.game!).appendingPathComponent(imageFilename)
|
||||
return imageFileURL
|
||||
}
|
||||
|
||||
var gameType: GameType {
|
||||
return self.game.type
|
||||
public var gameType: GameType {
|
||||
return self.game!.type
|
||||
}
|
||||
}
|
||||
|
||||
extension SaveState
|
||||
{
|
||||
override public func prepareForDeletion()
|
||||
|
||||
@NSManaged private var primitiveFilename: String
|
||||
@NSManaged private var primitiveIdentifier: String
|
||||
@NSManaged private var primitiveCreationDate: Date
|
||||
@NSManaged private var primitiveModifiedDate: Date
|
||||
|
||||
public override func awakeFromInsert()
|
||||
{
|
||||
super.awakeFromInsert()
|
||||
|
||||
let identifier = UUID().uuidString
|
||||
let date = Date()
|
||||
|
||||
self.primitiveIdentifier = identifier
|
||||
self.primitiveFilename = identifier
|
||||
self.primitiveCreationDate = date
|
||||
self.primitiveModifiedDate = date
|
||||
}
|
||||
|
||||
public override func prepareForDeletion()
|
||||
{
|
||||
super.prepareForDeletion()
|
||||
|
||||
@ -87,24 +70,3 @@ extension SaveState
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SaveState
|
||||
{
|
||||
@NSManaged private var primitiveFilename: String
|
||||
@NSManaged private var primitiveIdentifier: String
|
||||
@NSManaged private var primitiveCreationDate: Date
|
||||
@NSManaged private var primitiveModifiedDate: Date
|
||||
|
||||
override func awakeFromInsert()
|
||||
{
|
||||
super.awakeFromInsert()
|
||||
|
||||
let identifier = UUID().uuidString
|
||||
let date = Date()
|
||||
|
||||
self.primitiveIdentifier = identifier
|
||||
self.primitiveFilename = identifier
|
||||
self.primitiveCreationDate = date
|
||||
self.primitiveModifiedDate = date
|
||||
}
|
||||
}
|
||||
|
||||
36
Common/Database/Model/_Cheat.swift
Normal file
36
Common/Database/Model/_Cheat.swift
Normal file
@ -0,0 +1,36 @@
|
||||
// DO NOT EDIT. This file is machine-generated and constantly overwritten.
|
||||
// Make changes to Cheat.swift instead.
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import DeltaCore
|
||||
|
||||
public class _Cheat: NSManagedObject
|
||||
{
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Cheat> {
|
||||
return NSFetchRequest<Cheat>(entityName: "Cheat")
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
@NSManaged public var code: String
|
||||
|
||||
@NSManaged public var creationDate: Date
|
||||
|
||||
@NSManaged public var identifier: String
|
||||
|
||||
@NSManaged public var isEnabled: Bool
|
||||
|
||||
@NSManaged public var modifiedDate: Date
|
||||
|
||||
@NSManaged public var name: String?
|
||||
|
||||
@NSManaged public var type: CheatType
|
||||
|
||||
// MARK: - Relationships
|
||||
|
||||
@NSManaged public var game: Game?
|
||||
|
||||
}
|
||||
|
||||
38
Common/Database/Model/_Game.swift
Normal file
38
Common/Database/Model/_Game.swift
Normal file
@ -0,0 +1,38 @@
|
||||
// DO NOT EDIT. This file is machine-generated and constantly overwritten.
|
||||
// Make changes to Game.swift instead.
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import DeltaCore
|
||||
|
||||
public class _Game: NSManagedObject
|
||||
{
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Game> {
|
||||
return NSFetchRequest<Game>(entityName: "Game")
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
@NSManaged public var artworkURL: URL?
|
||||
|
||||
@NSManaged public var filename: String
|
||||
|
||||
@NSManaged public var identifier: String
|
||||
|
||||
@NSManaged public var name: String
|
||||
|
||||
@NSManaged public var type: GameType
|
||||
|
||||
// MARK: - Relationships
|
||||
|
||||
@NSManaged public var cheats: Set<Cheat>
|
||||
|
||||
@NSManaged public var gameCollections: Set<GameCollection>
|
||||
|
||||
@NSManaged public var previewSaveState: SaveState?
|
||||
|
||||
@NSManaged public var saveStates: Set<SaveState>
|
||||
|
||||
}
|
||||
|
||||
26
Common/Database/Model/_GameCollection.swift
Normal file
26
Common/Database/Model/_GameCollection.swift
Normal file
@ -0,0 +1,26 @@
|
||||
// DO NOT EDIT. This file is machine-generated and constantly overwritten.
|
||||
// Make changes to GameCollection.swift instead.
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import DeltaCore
|
||||
|
||||
public class _GameCollection: NSManagedObject
|
||||
{
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<GameCollection> {
|
||||
return NSFetchRequest<GameCollection>(entityName: "GameCollection")
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
@NSManaged public var identifier: String
|
||||
|
||||
@NSManaged public var index: Int16
|
||||
|
||||
// MARK: - Relationships
|
||||
|
||||
@NSManaged public var games: Set<Game>
|
||||
|
||||
}
|
||||
|
||||
36
Common/Database/Model/_SaveState.swift
Normal file
36
Common/Database/Model/_SaveState.swift
Normal file
@ -0,0 +1,36 @@
|
||||
// DO NOT EDIT. This file is machine-generated and constantly overwritten.
|
||||
// Make changes to SaveState.swift instead.
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import DeltaCore
|
||||
|
||||
public class _SaveState: NSManagedObject
|
||||
{
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<SaveState> {
|
||||
return NSFetchRequest<SaveState>(entityName: "SaveState")
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
@NSManaged public var creationDate: Date
|
||||
|
||||
@NSManaged public var filename: String
|
||||
|
||||
@NSManaged public var identifier: String
|
||||
|
||||
@NSManaged public var modifiedDate: Date
|
||||
|
||||
@NSManaged public var name: String?
|
||||
|
||||
@NSManaged public var type: SaveStateType
|
||||
|
||||
// MARK: - Relationships
|
||||
|
||||
@NSManaged public var game: Game?
|
||||
|
||||
@NSManaged public var previewGame: Game?
|
||||
|
||||
}
|
||||
|
||||
15
Common/Database/Model/mogenerator/templates/human.swift.motemplate
Executable file
15
Common/Database/Model/mogenerator/templates/human.swift.motemplate
Executable file
@ -0,0 +1,15 @@
|
||||
//
|
||||
// <$managedObjectClassName$>.swift
|
||||
// Delta
|
||||
//
|
||||
// Created by Riley Testut on 8/30/16.
|
||||
// Copyright (c) 2016 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc(<$managedObjectClassName$>)
|
||||
public class <$managedObjectClassName$>: _<$managedObjectClassName$>
|
||||
{
|
||||
// Custom logic goes here.
|
||||
}
|
||||
177
Common/Database/Model/mogenerator/templates/machine.swift.motemplate
Executable file
177
Common/Database/Model/mogenerator/templates/machine.swift.motemplate
Executable file
@ -0,0 +1,177 @@
|
||||
// DO NOT EDIT. This file is machine-generated and constantly overwritten.
|
||||
// Make changes to <$sanitizedManagedObjectClassName$>.swift instead.
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import DeltaCore
|
||||
|
||||
<$if noninheritedFetchedProperties.@count > 0$>
|
||||
public enum <$sanitizedManagedObjectClassName$>FetchedProperties: String
|
||||
{<$foreach FetchedProperty noninheritedFetchedProperties do$>
|
||||
case <$FetchedProperty.name$><$endforeach do$>
|
||||
}
|
||||
<$endif$>
|
||||
|
||||
<$if hasUserInfoKeys$>
|
||||
public enum <$sanitizedManagedObjectClassName$>UserInfo: String
|
||||
{<$foreach UserInfo userInfoKeyValues do$>
|
||||
case <$UserInfo.key$><$endforeach do$>
|
||||
}
|
||||
<$endif$>
|
||||
|
||||
|
||||
<$if hasCustomSuperentity $>
|
||||
public class _<$sanitizedManagedObjectClassName$>: <$customSuperentity$>
|
||||
{
|
||||
<$else$>
|
||||
public class _<$sanitizedManagedObjectClassName$>: NSManagedObject
|
||||
{<$endif$>
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<<$sanitizedManagedObjectClassName$>> {
|
||||
return NSFetchRequest<<$sanitizedManagedObjectClassName$>>(entityName: "<$sanitizedManagedObjectClassName$>")
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
<$foreach Attribute noninheritedAttributes do$>
|
||||
<$if Attribute.hasDefinedAttributeType$>
|
||||
<$if Attribute.hasScalarAttributeType$>
|
||||
<$if Attribute.isReadonly$>
|
||||
public var <$Attribute.name$>: NSNumber?
|
||||
{
|
||||
self.willAccessValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue)
|
||||
let <$Attribute.name$> = self.primitiveValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue) as? NSNumber
|
||||
self.didAccessValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue)
|
||||
return <$Attribute.name$>
|
||||
}
|
||||
<$else$>
|
||||
@NSManaged public var <$Attribute.name$>: <$Attribute.scalarAttributeType$><$if Attribute.isOptional$>?<$endif$>
|
||||
<$endif$>
|
||||
<$else$>
|
||||
<$if Attribute.isReadonly$>
|
||||
public var <$Attribute.name$>: <$Attribute.objectAttributeType$><$if Attribute.isOptional$>?<$endif$>
|
||||
{
|
||||
self.willAccessValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue)
|
||||
let <$Attribute.name$> = self.primitiveValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue) as? <$Attribute.objectAttributeType$>
|
||||
self.didAccessValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue)
|
||||
return <$Attribute.name$>
|
||||
}
|
||||
<$else$>
|
||||
@NSManaged public var <$Attribute.name$>: <$Attribute.objectAttributeType$><$if Attribute.isOptional$>?<$endif$>
|
||||
<$endif$>
|
||||
<$endif$>
|
||||
<$endif$>
|
||||
<$endforeach do$>
|
||||
|
||||
// MARK: - Relationships
|
||||
<$foreach Relationship noninheritedRelationships do$>
|
||||
<$if Relationship.isToMany$>
|
||||
@NSManaged public var <$Relationship.name$>: Set<<$Relationship.destinationEntity.sanitizedManagedObjectClassName$>>
|
||||
|
||||
<$else$>
|
||||
@NSManaged public var <$Relationship.name$>: <$Relationship.destinationEntity.sanitizedManagedObjectClassName$><$if Relationship.isOptional$>?<$endif$>
|
||||
<$endif$>
|
||||
<$endforeach do$>
|
||||
|
||||
<$foreach FetchRequest prettyFetchRequests do$>
|
||||
<$if FetchRequest.singleResult$>
|
||||
class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>) -> AnyObject? {
|
||||
return self.fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.name$><$endforeach do2$>, error: nil)
|
||||
}
|
||||
|
||||
class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>, error outError: NSErrorPointer) -> AnyObject? {
|
||||
guard let psc = managedObjectContext.persistentStoreCoordinator else { return nil }
|
||||
let model = psc.managedObjectModel
|
||||
let substitutionVariables = [<$if FetchRequest.hasBindings$><$foreach Binding FetchRequest.bindings do2$>
|
||||
"<$Binding.name$>": <$Binding.name$>,
|
||||
<$endforeach do2$><$endif$>
|
||||
]
|
||||
|
||||
guard let fetchRequest = model.fetchRequestFromTemplateWithName("<$FetchRequest.name$>", substitutionVariables: substitutionVariables) else {
|
||||
assert(false, "Can't find fetch request named \"<$FetchRequest.name$>\".")
|
||||
return nil
|
||||
}
|
||||
|
||||
var result: AnyObject? = nil
|
||||
do {
|
||||
let results = try managedObjectContext.executeFetchRequest(fetchRequest)
|
||||
switch results.count {
|
||||
case 0:
|
||||
// Nothing found matching the fetch request. That's cool, though: we'll just return nil.
|
||||
break
|
||||
case 1:
|
||||
result = results.first
|
||||
default:
|
||||
print("WARN fetch request <$FetchRequest.name$>: 0 or 1 objects expected, \(results.count) found (substitutionVariables: \(substitutionVariables), results: \(results))")
|
||||
}
|
||||
|
||||
} catch {
|
||||
print("Error executing fetch request: \(error)")
|
||||
}
|
||||
return result
|
||||
}
|
||||
<$else$>
|
||||
class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>) -> [AnyObject]? {
|
||||
return self.fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.name$><$endforeach do2$>, error: nil)
|
||||
}
|
||||
|
||||
class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>, error outError: NSErrorPointer) -> [AnyObject]? {
|
||||
guard let psc = managedObjectContext.persistentStoreCoordinator else { return nil }
|
||||
let model = psc.managedObjectModel
|
||||
let substitutionVariables : [String : AnyObject] = [<$if FetchRequest.hasBindings$><$foreach Binding FetchRequest.bindings do2$>
|
||||
"<$Binding.name$>": <$Binding.name$>,
|
||||
<$endforeach do2$><$else$>:<$endif$>]
|
||||
|
||||
let fetchRequest = model.fetchRequestFromTemplateWithName("<$FetchRequest.name$>", substitutionVariables: substitutionVariables)
|
||||
assert(fetchRequest != nil, "Can't find fetch request named \"<$FetchRequest.name$>\".")
|
||||
|
||||
var results = Array<AnyObject>()
|
||||
do {
|
||||
results = try managedObjectContext.executeFetchRequest(fetchRequest!)
|
||||
} catch {
|
||||
print("Error executing fetch request: \(error)")
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
<$endif$>
|
||||
<$endforeach do$>
|
||||
|
||||
<$foreach FetchedProperty noninheritedFetchedProperties do$>
|
||||
@NSManaged public
|
||||
let <$FetchedProperty.name$>: [<$FetchedProperty.entity.sanitizedManagedObjectClassName$>]
|
||||
<$endforeach do$>
|
||||
}
|
||||
|
||||
<$foreach Relationship noninheritedRelationships do$>
|
||||
<$if Relationship.isToMany$>
|
||||
<$if Relationship.jr_isOrdered$>
|
||||
extension _<$sanitizedManagedObjectClassName$> {
|
||||
|
||||
func add<$Relationship.name.initialCapitalString$>(objects: <$Relationship.immutableCollectionClassName$>) {
|
||||
let mutable = self.<$Relationship.name$>.mutableCopy() as! NSMutable<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set
|
||||
mutable.union<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set(objects<$if !Relationship.jr_isOrdered$> as Set<NSObject><$endif$>)
|
||||
self.<$Relationship.name$> = mutable.copy() as! NS<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set
|
||||
}
|
||||
|
||||
func remove<$Relationship.name.initialCapitalString$>(objects: <$Relationship.immutableCollectionClassName$>) {
|
||||
let mutable = self.<$Relationship.name$>.mutableCopy() as! NSMutable<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set
|
||||
mutable.minus<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set(objects<$if !Relationship.jr_isOrdered$> as Set<NSObject><$endif$>)
|
||||
self.<$Relationship.name$> = mutable.copy() as! NS<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set
|
||||
}
|
||||
|
||||
func add<$Relationship.name.initialCapitalString$>Object(value: <$Relationship.destinationEntity.sanitizedManagedObjectClassName$>) {
|
||||
let mutable = self.<$Relationship.name$>.mutableCopy() as! NSMutable<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set
|
||||
mutable.addObject(value)
|
||||
self.<$Relationship.name$> = mutable.copy() as! NS<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set
|
||||
}
|
||||
|
||||
func remove<$Relationship.name.initialCapitalString$>Object(value: <$Relationship.destinationEntity.sanitizedManagedObjectClassName$>) {
|
||||
let mutable = self.<$Relationship.name$>.mutableCopy() as! NSMutable<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set
|
||||
mutable.removeObject(value)
|
||||
self.<$Relationship.name$> = mutable.copy() as! NS<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set
|
||||
}
|
||||
|
||||
}
|
||||
<$endif$>
|
||||
<$endif$>
|
||||
<$endforeach do$>
|
||||
@ -90,7 +90,7 @@ class GamePickerController: NSObject
|
||||
|
||||
DatabaseManager.shared.viewContext.perform() {
|
||||
|
||||
let predicate = NSPredicate(format: "%K IN (%@)", Game.Attributes.identifier.rawValue, identifiers)
|
||||
let predicate = NSPredicate(format: "%K IN (%@)", #keyPath(Game.identifier), identifiers)
|
||||
let games = Game.instancesWithPredicate(predicate, inManagedObjectContext: DatabaseManager.shared.viewContext, type: Game.self)
|
||||
|
||||
self.delegate?.gamePickerController(self, didImportGames: games)
|
||||
|
||||
@ -18,8 +18,16 @@
|
||||
BF13A7581D5D2FD9000BB055 /* EmulatorCore+Cheats.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF13A7571D5D2FD9000BB055 /* EmulatorCore+Cheats.swift */; };
|
||||
BF172AEB1C68986300C26774 /* NSManagedObjectContext+Conveniences.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF172AEA1C68986300C26774 /* NSManagedObjectContext+Conveniences.swift */; };
|
||||
BF1DAD5D1D9F576000E752A7 /* GameTypeControllerSkinsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF1DAD5C1D9F576000E752A7 /* GameTypeControllerSkinsViewController.swift */; };
|
||||
BF1FB1861C5EE643007E2494 /* SaveState.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF1FB1831C5EE643007E2494 /* SaveState.swift */; };
|
||||
BF27CC8E1BC9FEA200A20D89 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF6BB2451BB73FE800CCF94A /* Assets.xcassets */; };
|
||||
BF28980D1DAAFB640023D8E9 /* Delta.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = BF28980B1DAAFB640023D8E9 /* Delta.xcdatamodeld */; };
|
||||
BF2898151DAAFC2A0023D8E9 /* Cheat.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF2898111DAAFC2A0023D8E9 /* Cheat.swift */; };
|
||||
BF2898161DAAFC2A0023D8E9 /* Game.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF2898121DAAFC2A0023D8E9 /* Game.swift */; };
|
||||
BF2898171DAAFC2A0023D8E9 /* GameCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF2898131DAAFC2A0023D8E9 /* GameCollection.swift */; };
|
||||
BF2898181DAAFC2A0023D8E9 /* SaveState.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF2898141DAAFC2A0023D8E9 /* SaveState.swift */; };
|
||||
BF2898211DAAFD720023D8E9 /* _Cheat.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF2898191DAAFC330023D8E9 /* _Cheat.swift */; };
|
||||
BF2898221DAAFD720023D8E9 /* _Game.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF28981A1DAAFC330023D8E9 /* _Game.swift */; };
|
||||
BF2898231DAAFD720023D8E9 /* _GameCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF28981B1DAAFC330023D8E9 /* _GameCollection.swift */; };
|
||||
BF2898241DAAFD720023D8E9 /* _SaveState.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF28981C1DAAFC330023D8E9 /* _SaveState.swift */; };
|
||||
BF2B98E61C97E32F00F6D57D /* SaveStatesCollectionHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF2B98E51C97E32F00F6D57D /* SaveStatesCollectionHeaderView.swift */; };
|
||||
BF31878B1D489AAA00BD020D /* CheatValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF31878A1D489AAA00BD020D /* CheatValidator.swift */; };
|
||||
BF34FA071CF0F510006624C7 /* EditCheatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF34FA061CF0F510006624C7 /* EditCheatViewController.swift */; };
|
||||
@ -31,10 +39,8 @@
|
||||
BF3540001C5DA3C500C1184C /* PausePresentationControllerContentView.xib in Resources */ = {isa = PBXBuildFile; fileRef = BF353FFE1C5DA3C500C1184C /* PausePresentationControllerContentView.xib */; };
|
||||
BF3540021C5DA3D500C1184C /* PauseStoryboardSegue.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3540011C5DA3D500C1184C /* PauseStoryboardSegue.swift */; };
|
||||
BF3540081C5DAFAD00C1184C /* PauseTransitionCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3540071C5DAFAD00C1184C /* PauseTransitionCoordinator.swift */; };
|
||||
BF4566E81BC090B6007BFA1A /* Model.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = BF4566E61BC090B6007BFA1A /* Model.xcdatamodeld */; };
|
||||
BF5E7F441B9A650B00AE44F8 /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF5E7F431B9A650B00AE44F8 /* SettingsViewController.swift */; };
|
||||
BF5E7F461B9A652600AE44F8 /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF5E7F451B9A652600AE44F8 /* Settings.storyboard */; };
|
||||
BF65E8631CEE5C6A00CD3247 /* Cheat.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF65E8621CEE5C6A00CD3247 /* Cheat.swift */; };
|
||||
BF696B801D9B2B02009639E0 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF696B7F1D9B2B02009639E0 /* Theme.swift */; };
|
||||
BF70798C1B6B464B0019077C /* ZipZap.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF70798B1B6B464B0019077C /* ZipZap.framework */; };
|
||||
BF70798D1B6B464B0019077C /* ZipZap.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BF70798B1B6B464B0019077C /* ZipZap.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
@ -52,14 +58,12 @@
|
||||
BFA2315C1CED10BE0011E35A /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFA2315B1CED10BE0011E35A /* Action.swift */; };
|
||||
BFAA1FED1B8AA4FA00495943 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFAA1FEC1B8AA4FA00495943 /* Settings.swift */; };
|
||||
BFBAA86A1D5A483900A29C1B /* DatabaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBAA8691D5A483900A29C1B /* DatabaseManager.swift */; };
|
||||
BFC2731A1BE6152200D22B05 /* GameCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFC273171BE6152200D22B05 /* GameCollection.swift */; };
|
||||
BFC9B7391CEFCD34008629BB /* CheatsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFC9B7381CEFCD34008629BB /* CheatsViewController.swift */; };
|
||||
BFCEA67E1D56FF640061A534 /* UIViewControllerContextTransitioning+Conveniences.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFCEA67D1D56FF640061A534 /* UIViewControllerContextTransitioning+Conveniences.swift */; };
|
||||
BFD097211D3A01B8005A44C2 /* SaveStatesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3540041C5DA70400C1184C /* SaveStatesViewController.swift */; };
|
||||
BFDB28451BC9DA7B001D0C83 /* GamePickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFDB28441BC9DA7B001D0C83 /* GamePickerController.swift */; };
|
||||
BFDD04EF1D5E27DB002D450E /* NSFetchedResultsController+Conveniences.m in Sources */ = {isa = PBXBuildFile; fileRef = BF02BCFF1D361BD1000892F2 /* NSFetchedResultsController+Conveniences.m */; };
|
||||
BFDD04F11D5E2C27002D450E /* GameCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFDD04F01D5E2C27002D450E /* GameCollectionViewController.swift */; };
|
||||
BFDE393C1BC0CEDF003F72E8 /* Game.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFDE39391BC0CEDF003F72E8 /* Game.swift */; };
|
||||
BFE4269E1D9C68E600DC913F /* SaveStatesStoryboardSegue.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFE4269D1D9C68E600DC913F /* SaveStatesStoryboardSegue.swift */; };
|
||||
BFE704F51CEA426E0058BAC8 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22506DA00971C4300AF90A35 /* Pods.framework */; };
|
||||
BFEC732D1AAECC4A00650035 /* Roxas.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BFEC732C1AAECC4A00650035 /* Roxas.framework */; };
|
||||
@ -110,10 +114,18 @@
|
||||
BF13A7571D5D2FD9000BB055 /* EmulatorCore+Cheats.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "EmulatorCore+Cheats.swift"; sourceTree = "<group>"; };
|
||||
BF172AEA1C68986300C26774 /* NSManagedObjectContext+Conveniences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObjectContext+Conveniences.swift"; sourceTree = "<group>"; };
|
||||
BF1DAD5C1D9F576000E752A7 /* GameTypeControllerSkinsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GameTypeControllerSkinsViewController.swift; path = "Controller Skins/GameTypeControllerSkinsViewController.swift"; sourceTree = "<group>"; };
|
||||
BF1FB1831C5EE643007E2494 /* SaveState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SaveState.swift; sourceTree = "<group>"; };
|
||||
BF27CC861BC9E3C600A20D89 /* Delta.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Delta.entitlements; sourceTree = "<group>"; };
|
||||
BF27CC8A1BC9FE4D00A20D89 /* Pods.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Pods.framework; path = "Pods/../build/Debug-appletvos/Pods.framework"; sourceTree = "<group>"; };
|
||||
BF27CC941BCB7B7A00A20D89 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.0.sdk/System/Library/Frameworks/GameController.framework; sourceTree = DEVELOPER_DIR; };
|
||||
BF28980C1DAAFB640023D8E9 /* Model.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model.xcdatamodel; sourceTree = "<group>"; };
|
||||
BF2898111DAAFC2A0023D8E9 /* Cheat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cheat.swift; sourceTree = "<group>"; };
|
||||
BF2898121DAAFC2A0023D8E9 /* Game.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Game.swift; sourceTree = "<group>"; };
|
||||
BF2898131DAAFC2A0023D8E9 /* GameCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameCollection.swift; sourceTree = "<group>"; };
|
||||
BF2898141DAAFC2A0023D8E9 /* SaveState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SaveState.swift; sourceTree = "<group>"; };
|
||||
BF2898191DAAFC330023D8E9 /* _Cheat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = _Cheat.swift; sourceTree = "<group>"; };
|
||||
BF28981A1DAAFC330023D8E9 /* _Game.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = _Game.swift; sourceTree = "<group>"; };
|
||||
BF28981B1DAAFC330023D8E9 /* _GameCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = _GameCollection.swift; sourceTree = "<group>"; };
|
||||
BF28981C1DAAFC330023D8E9 /* _SaveState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = _SaveState.swift; sourceTree = "<group>"; };
|
||||
BF2B98E51C97E32F00F6D57D /* SaveStatesCollectionHeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SaveStatesCollectionHeaderView.swift; path = "Pause Menu/Save States/SaveStatesCollectionHeaderView.swift"; sourceTree = "<group>"; };
|
||||
BF31878A1D489AAA00BD020D /* CheatValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CheatValidator.swift; path = "Pause Menu/Cheats/CheatValidator.swift"; sourceTree = "<group>"; };
|
||||
BF34FA061CF0F510006624C7 /* EditCheatViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EditCheatViewController.swift; path = "Pause Menu/Cheats/EditCheatViewController.swift"; sourceTree = "<group>"; };
|
||||
@ -126,11 +138,9 @@
|
||||
BF3540011C5DA3D500C1184C /* PauseStoryboardSegue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PauseStoryboardSegue.swift; path = "Pause Menu/Segues/PauseStoryboardSegue.swift"; sourceTree = "<group>"; };
|
||||
BF3540041C5DA70400C1184C /* SaveStatesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SaveStatesViewController.swift; path = "Pause Menu/Save States/SaveStatesViewController.swift"; sourceTree = "<group>"; };
|
||||
BF3540071C5DAFAD00C1184C /* PauseTransitionCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PauseTransitionCoordinator.swift; path = "Pause Menu/Segues/PauseTransitionCoordinator.swift"; sourceTree = "<group>"; };
|
||||
BF4566E71BC090B6007BFA1A /* Model.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model.xcdatamodel; sourceTree = "<group>"; };
|
||||
BF5E7F431B9A650B00AE44F8 /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
|
||||
BF5E7F451B9A652600AE44F8 /* Settings.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Settings.storyboard; sourceTree = "<group>"; };
|
||||
BF63BDE91D389EEB00FCB040 /* GameViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = "<group>"; };
|
||||
BF65E8621CEE5C6A00CD3247 /* Cheat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cheat.swift; sourceTree = "<group>"; };
|
||||
BF696B7F1D9B2B02009639E0 /* Theme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Theme.swift; path = Theming/Theme.swift; sourceTree = "<group>"; };
|
||||
BF6BB2451BB73FE800CCF94A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
BF70798B1B6B464B0019077C /* ZipZap.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ZipZap.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@ -145,12 +155,10 @@
|
||||
BFAA1FEC1B8AA4FA00495943 /* Settings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
|
||||
BFBAA8691D5A483900A29C1B /* DatabaseManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseManager.swift; sourceTree = "<group>"; };
|
||||
BFC134E01AAD82460087AD7B /* SNESDeltaCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SNESDeltaCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BFC273171BE6152200D22B05 /* GameCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameCollection.swift; sourceTree = "<group>"; };
|
||||
BFC9B7381CEFCD34008629BB /* CheatsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CheatsViewController.swift; path = "Pause Menu/Cheats/CheatsViewController.swift"; sourceTree = "<group>"; };
|
||||
BFCEA67D1D56FF640061A534 /* UIViewControllerContextTransitioning+Conveniences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewControllerContextTransitioning+Conveniences.swift"; sourceTree = "<group>"; };
|
||||
BFDB28441BC9DA7B001D0C83 /* GamePickerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GamePickerController.swift; sourceTree = "<group>"; };
|
||||
BFDD04F01D5E2C27002D450E /* GameCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameCollectionViewController.swift; sourceTree = "<group>"; };
|
||||
BFDE39391BC0CEDF003F72E8 /* Game.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Game.swift; sourceTree = "<group>"; };
|
||||
BFE4269D1D9C68E600DC913F /* SaveStatesStoryboardSegue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SaveStatesStoryboardSegue.swift; path = Segues/SaveStatesStoryboardSegue.swift; sourceTree = "<group>"; };
|
||||
BFEC732C1AAECC4A00650035 /* Roxas.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Roxas.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BFFA71D71AAC406100EE9DD1 /* Delta.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Delta.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@ -221,6 +229,28 @@
|
||||
name = "Controller Skins";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BF28980F1DAAFC0E0023D8E9 /* Human */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BF2898111DAAFC2A0023D8E9 /* Cheat.swift */,
|
||||
BF2898121DAAFC2A0023D8E9 /* Game.swift */,
|
||||
BF2898131DAAFC2A0023D8E9 /* GameCollection.swift */,
|
||||
BF2898141DAAFC2A0023D8E9 /* SaveState.swift */,
|
||||
);
|
||||
name = Human;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BF2898101DAAFC120023D8E9 /* Machine */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BF2898191DAAFC330023D8E9 /* _Cheat.swift */,
|
||||
BF28981A1DAAFC330023D8E9 /* _Game.swift */,
|
||||
BF28981B1DAAFC330023D8E9 /* _GameCollection.swift */,
|
||||
BF28981C1DAAFC330023D8E9 /* _SaveState.swift */,
|
||||
);
|
||||
name = Machine;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BF353FFB1C5DA2F600C1184C /* Presentation Controller */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -263,11 +293,9 @@
|
||||
BF4566E51BC09033007BFA1A /* Model */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BF4566E61BC090B6007BFA1A /* Model.xcdatamodeld */,
|
||||
BFDE39391BC0CEDF003F72E8 /* Game.swift */,
|
||||
BFC273171BE6152200D22B05 /* GameCollection.swift */,
|
||||
BF1FB1831C5EE643007E2494 /* SaveState.swift */,
|
||||
BF65E8621CEE5C6A00CD3247 /* Cheat.swift */,
|
||||
BF28980B1DAAFB640023D8E9 /* Delta.xcdatamodeld */,
|
||||
BF28980F1DAAFC0E0023D8E9 /* Human */,
|
||||
BF2898101DAAFC120023D8E9 /* Machine */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
@ -488,6 +516,7 @@
|
||||
BF9F4FCC1AAD7AEE004C9500 /* Embed Frameworks */,
|
||||
AA90DB8D72559A44728B98F0 /* Copy Pods Resources */,
|
||||
AEE0EDDF2E4AAD91E135FE80 /* Embed Pods Frameworks */,
|
||||
BF28980A1DAAFB0F0023D8E9 /* mogenerator */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@ -600,6 +629,20 @@
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
BF28980A1DAAFB0F0023D8E9 /* mogenerator */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = mogenerator;
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/usr/local/bin/mogenerator -m \"Common/Database/Model/Delta.xcdatamodeld\" -O \"Common/Database/Model\" --swift --template-var scalarsWhenNonOptional=true --template-path \"Common/Database/Model/mogenerator/templates\"";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
@ -610,7 +653,7 @@
|
||||
BF3540081C5DAFAD00C1184C /* PauseTransitionCoordinator.swift in Sources */,
|
||||
BFAA1FED1B8AA4FA00495943 /* Settings.swift in Sources */,
|
||||
BF7AE8241C2E984300B1B5BC /* GridCollectionViewLayout.swift in Sources */,
|
||||
BF1FB1861C5EE643007E2494 /* SaveState.swift in Sources */,
|
||||
BF28980D1DAAFB640023D8E9 /* Delta.xcdatamodeld in Sources */,
|
||||
BFA0D1271D3AE1F600565894 /* GameViewController.swift in Sources */,
|
||||
BF13A7581D5D2FD9000BB055 /* EmulatorCore+Cheats.swift in Sources */,
|
||||
BF31878B1D489AAA00BD020D /* CheatValidator.swift in Sources */,
|
||||
@ -621,17 +664,17 @@
|
||||
BFDD04F11D5E2C27002D450E /* GameCollectionViewController.swift in Sources */,
|
||||
BFE4269E1D9C68E600DC913F /* SaveStatesStoryboardSegue.swift in Sources */,
|
||||
BFFA71DD1AAC406100EE9DD1 /* AppDelegate.swift in Sources */,
|
||||
BF2898241DAAFD720023D8E9 /* _SaveState.swift in Sources */,
|
||||
BF7AE81E1C2E984300B1B5BC /* GridCollectionViewCell.swift in Sources */,
|
||||
BF34FA111CF1899D006624C7 /* CheatTextView.swift in Sources */,
|
||||
BF1DAD5D1D9F576000E752A7 /* GameTypeControllerSkinsViewController.swift in Sources */,
|
||||
BFFC46231D5984A000AF2CC6 /* LaunchViewController.swift in Sources */,
|
||||
BF4566E81BC090B6007BFA1A /* Model.xcdatamodeld in Sources */,
|
||||
BFDE393C1BC0CEDF003F72E8 /* Game.swift in Sources */,
|
||||
BF34FA071CF0F510006624C7 /* EditCheatViewController.swift in Sources */,
|
||||
BF11734D1DA32A5200047DF8 /* GameType+Localization.swift in Sources */,
|
||||
BFC2731A1BE6152200D22B05 /* GameCollection.swift in Sources */,
|
||||
BFFC461F1D59823500AF2CC6 /* GamesStoryboardSegue.swift in Sources */,
|
||||
BF2898211DAAFD720023D8E9 /* _Cheat.swift in Sources */,
|
||||
BF2B98E61C97E32F00F6D57D /* SaveStatesCollectionHeaderView.swift in Sources */,
|
||||
BF2898221DAAFD720023D8E9 /* _Game.swift in Sources */,
|
||||
BF762EAB1BC1B076002C8866 /* NSManagedObject+Conveniences.swift in Sources */,
|
||||
BFC9B7391CEFCD34008629BB /* CheatsViewController.swift in Sources */,
|
||||
BF353FFF1C5DA3C500C1184C /* PausePresentationController.swift in Sources */,
|
||||
@ -640,19 +683,23 @@
|
||||
BF090CF41B490D8300DCAB45 /* UIDevice+Vibration.m in Sources */,
|
||||
BF797A2D1C2D339F00F1A000 /* UILabel+FontSize.swift in Sources */,
|
||||
BFD097211D3A01B8005A44C2 /* SaveStatesViewController.swift in Sources */,
|
||||
BF65E8631CEE5C6A00CD3247 /* Cheat.swift in Sources */,
|
||||
BF3540021C5DA3D500C1184C /* PauseStoryboardSegue.swift in Sources */,
|
||||
BF0CDDAD1C8155D200640168 /* LoadImageOperation.swift in Sources */,
|
||||
BF2898171DAAFC2A0023D8E9 /* GameCollection.swift in Sources */,
|
||||
BF107EC41BF413F000E0C32C /* GamesViewController.swift in Sources */,
|
||||
BF2898181DAAFC2A0023D8E9 /* SaveState.swift in Sources */,
|
||||
BF172AEB1C68986300C26774 /* NSManagedObjectContext+Conveniences.swift in Sources */,
|
||||
BF13A7561D5D29B0000BB055 /* PreviewGameViewController.swift in Sources */,
|
||||
BFDD04EF1D5E27DB002D450E /* NSFetchedResultsController+Conveniences.m in Sources */,
|
||||
BFCEA67E1D56FF640061A534 /* UIViewControllerContextTransitioning+Conveniences.swift in Sources */,
|
||||
BF2898161DAAFC2A0023D8E9 /* Game.swift in Sources */,
|
||||
BF1173501DA32CF600047DF8 /* ControllersSettingsViewController.swift in Sources */,
|
||||
BFFC461E1D59823500AF2CC6 /* GamesPresentationController.swift in Sources */,
|
||||
BF5E7F441B9A650B00AE44F8 /* SettingsViewController.swift in Sources */,
|
||||
BF2898231DAAFD720023D8E9 /* _GameCollection.swift in Sources */,
|
||||
BF353FF21C5D7FB000C1184C /* PauseViewController.swift in Sources */,
|
||||
BFDB28451BC9DA7B001D0C83 /* GamePickerController.swift in Sources */,
|
||||
BF2898151DAAFC2A0023D8E9 /* Cheat.swift in Sources */,
|
||||
BF696B801D9B2B02009639E0 /* Theme.swift in Sources */,
|
||||
BF7AE8081C2E858400B1B5BC /* PauseMenuViewController.swift in Sources */,
|
||||
);
|
||||
@ -832,13 +879,13 @@
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCVersionGroup section */
|
||||
BF4566E61BC090B6007BFA1A /* Model.xcdatamodeld */ = {
|
||||
BF28980B1DAAFB640023D8E9 /* Delta.xcdatamodeld */ = {
|
||||
isa = XCVersionGroup;
|
||||
children = (
|
||||
BF4566E71BC090B6007BFA1A /* Model.xcdatamodel */,
|
||||
BF28980C1DAAFB640023D8E9 /* Model.xcdatamodel */,
|
||||
);
|
||||
currentVersion = BF4566E71BC090B6007BFA1A /* Model.xcdatamodel */;
|
||||
path = Model.xcdatamodeld;
|
||||
currentVersion = BF28980C1DAAFB640023D8E9 /* Model.xcdatamodel */;
|
||||
path = Delta.xcdatamodeld;
|
||||
sourceTree = "<group>";
|
||||
versionGroupType = wrapper.xcdatamodel;
|
||||
};
|
||||
|
||||
@ -386,7 +386,7 @@ extension GameViewController: SaveStatesViewControllerDelegate
|
||||
|
||||
let predicate = NSPredicate(format: "%K == %d AND %K == %@", #keyPath(SaveState.type), SaveStateType.auto.rawValue, #keyPath(SaveState.game), game)
|
||||
|
||||
let fetchRequest = SaveState.fetchRequest()
|
||||
let fetchRequest: NSFetchRequest<SaveState> = SaveState.fetchRequest()
|
||||
fetchRequest.predicate = predicate
|
||||
fetchRequest.sortDescriptors = [NSSortDescriptor(key: #keyPath(SaveState.creationDate), ascending: true)]
|
||||
|
||||
@ -394,7 +394,7 @@ extension GameViewController: SaveStatesViewControllerDelegate
|
||||
|
||||
do
|
||||
{
|
||||
saveStates = try fetchRequest.execute() as? [SaveState]
|
||||
saveStates = try fetchRequest.execute()
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@ -41,12 +41,12 @@ extension EmulatorCore
|
||||
let backgroundContext = DatabaseManager.shared.newBackgroundContext()
|
||||
backgroundContext.performAndWait {
|
||||
|
||||
let predicate = NSPredicate(format: "%K == %@", Cheat.Attributes.game.rawValue, game)
|
||||
let predicate = NSPredicate(format: "%K == %@", #keyPath(Cheat.game), game)
|
||||
|
||||
let cheats = Cheat.instancesWithPredicate(predicate, inManagedObjectContext: backgroundContext, type: Cheat.self)
|
||||
for cheat in cheats
|
||||
{
|
||||
if cheat.enabled
|
||||
if cheat.isEnabled
|
||||
{
|
||||
self.activateCheatWithErrorLogging(cheat)
|
||||
}
|
||||
|
||||
@ -28,12 +28,12 @@ struct CheatValidator
|
||||
|
||||
func validate(_ cheat: Cheat) throws
|
||||
{
|
||||
guard let name = cheat.name else { throw Error.invalidName }
|
||||
guard let name = cheat.name, let game = cheat.game else { throw Error.invalidName }
|
||||
|
||||
let code = cheat.code
|
||||
|
||||
// Find all cheats that are for the same game, don't have the same identifier as the current cheat, but have either the same name or code
|
||||
let predicate = NSPredicate(format: "%K == %@ AND %K != %@ AND (%K == %@ OR %K == %@)", Cheat.Attributes.game.rawValue, cheat.game, Cheat.Attributes.identifier.rawValue, cheat.identifier, Cheat.Attributes.code.rawValue, code, Cheat.Attributes.name.rawValue, name)
|
||||
let predicate = NSPredicate(format: "%K == %@ AND %K != %@ AND (%K == %@ OR %K == %@)", #keyPath(Cheat.game), game, #keyPath(Cheat.identifier), cheat.identifier, #keyPath(Cheat.code), code, #keyPath(Cheat.name), name)
|
||||
|
||||
let cheats = Cheat.instancesWithPredicate(predicate, inManagedObjectContext: self.managedObjectContext, type: Cheat.self)
|
||||
for cheat in cheats
|
||||
|
||||
@ -94,8 +94,8 @@ private extension CheatsViewController
|
||||
{
|
||||
let fetchRequest = Cheat.rst_fetchRequest()
|
||||
fetchRequest.returnsObjectsAsFaults = false
|
||||
fetchRequest.predicate = NSPredicate(format: "%K == %@", Cheat.Attributes.game.rawValue, self.game)
|
||||
fetchRequest.sortDescriptors = [NSSortDescriptor(key: Cheat.Attributes.name.rawValue, ascending: true)]
|
||||
fetchRequest.predicate = NSPredicate(format: "%K == %@", #keyPath(Cheat.game), self.game)
|
||||
fetchRequest.sortDescriptors = [NSSortDescriptor(key: #keyPath(Cheat.name), ascending: true)]
|
||||
|
||||
self.fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext, sectionNameKeyPath: nil, cacheName: nil)
|
||||
self.fetchedResultsController.delegate = self
|
||||
@ -148,7 +148,7 @@ private extension CheatsViewController
|
||||
cell.textLabel?.text = cheat.name
|
||||
cell.textLabel?.font = UIFont.boldSystemFont(ofSize: cell.textLabel!.font.pointSize)
|
||||
cell.textLabel?.textColor = UIColor.white
|
||||
cell.accessoryType = cheat.enabled ? .checkmark : .none
|
||||
cell.accessoryType = cheat.isEnabled ? .checkmark : .none
|
||||
}
|
||||
|
||||
func makeEditCheatViewController(cheat: Cheat?) -> EditCheatViewController
|
||||
@ -195,9 +195,9 @@ extension CheatsViewController
|
||||
let backgroundContext = DatabaseManager.shared.newBackgroundContext()
|
||||
backgroundContext.performAndWait {
|
||||
let temporaryCheat = backgroundContext.object(with: cheat.objectID) as! Cheat
|
||||
temporaryCheat.enabled = !temporaryCheat.enabled
|
||||
temporaryCheat.isEnabled = !temporaryCheat.isEnabled
|
||||
|
||||
if temporaryCheat.enabled
|
||||
if temporaryCheat.isEnabled
|
||||
{
|
||||
self.delegate?.cheatsViewController(self, activateCheat: temporaryCheat)
|
||||
}
|
||||
|
||||
@ -116,13 +116,13 @@ extension EditCheatViewController
|
||||
else
|
||||
{
|
||||
self.mutableCheat = Cheat.insertIntoManagedObjectContext(self.managedObjectContext)
|
||||
self.mutableCheat.game = self.managedObjectContext.object(with: self.game.objectID) as! Game
|
||||
self.mutableCheat.game = self.managedObjectContext.object(with: self.game.objectID) as? Game
|
||||
self.mutableCheat.type = self.supportedCheatFormats.first!.type
|
||||
self.mutableCheat.code = ""
|
||||
self.mutableCheat.name = ""
|
||||
}
|
||||
|
||||
self.mutableCheat.enabled = true // After we save a cheat, it should be enabled
|
||||
self.mutableCheat.isEnabled = true // After we save a cheat, it should be enabled
|
||||
|
||||
name = self.mutableCheat.name
|
||||
type = self.mutableCheat.type
|
||||
|
||||
@ -169,10 +169,10 @@ private extension SaveStatesViewController
|
||||
{
|
||||
let fetchRequest = SaveState.rst_fetchRequest()
|
||||
fetchRequest.returnsObjectsAsFaults = false
|
||||
fetchRequest.predicate = NSPredicate(format: "%K == %@", SaveState.Attributes.game.rawValue, self.game)
|
||||
fetchRequest.sortDescriptors = [NSSortDescriptor(key: SaveState.Attributes.type.rawValue, ascending: true), NSSortDescriptor(key: SaveState.Attributes.creationDate.rawValue, ascending: true)]
|
||||
fetchRequest.predicate = NSPredicate(format: "%K == %@", #keyPath(SaveState.game), self.game)
|
||||
fetchRequest.sortDescriptors = [NSSortDescriptor(key: #keyPath(SaveState.type), ascending: true), NSSortDescriptor(key: #keyPath(SaveState.creationDate), ascending: true)]
|
||||
|
||||
self.fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext, sectionNameKeyPath: SaveState.Attributes.type.rawValue, cacheName: nil)
|
||||
self.fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext, sectionNameKeyPath: #keyPath(SaveState.type), cacheName: nil)
|
||||
self.fetchedResultsController.delegate = self
|
||||
}
|
||||
|
||||
@ -482,7 +482,7 @@ private extension SaveStatesViewController
|
||||
|
||||
if self.traitCollection.forceTouchCapability == .available
|
||||
{
|
||||
if saveState.game.previewSaveState != saveState
|
||||
if saveState.game?.previewSaveState != saveState
|
||||
{
|
||||
let previewAction = Action(title: NSLocalizedString("Set as Preview Save State", comment: ""), style: .default, action: { [unowned self] action in
|
||||
self.updatePreviewSaveState(saveState)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user