Skip to content

Commit

Permalink
manually generate the core data classes
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy committed Mar 5, 2024
1 parent 540dcc5 commit c1a8ea4
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ let package = Package(
"Common"
],
resources: [
.process("BrowsingHistory.xcdatamodeld")
.process("CoreData/BrowsingHistory.xcdatamodeld")
],
swiftSettings: [
.define("DEBUG", .when(configuration: .debug))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22522" systemVersion="23B92" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithSwiftData="YES" userDefinedModelVersionIdentifier="">
<entity name="BrowsingHistoryEntryManagedObject" representedClassName="BrowsingHistoryEntryManagedObject" syncable="YES" codeGenerationType="class">
<entity name="BrowsingHistoryEntryManagedObject" representedClassName="BrowsingHistoryEntryManagedObject" syncable="YES">
<attribute name="blockedTrackingEntities" optional="YES" attributeType="String"/>
<attribute name="failedToLoad" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="identifier" attributeType="UUID" usesScalarValueType="NO"/>
Expand All @@ -12,7 +12,7 @@
<attribute name="url" attributeType="URI" valueTransformerName="NSURLTransformer"/>
<relationship name="visits" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="PageVisitManagedObject" inverseName="historyEntry" inverseEntity="PageVisitManagedObject"/>
</entity>
<entity name="PageVisitManagedObject" representedClassName="PageVisitManagedObject" syncable="YES" codeGenerationType="class">
<entity name="PageVisitManagedObject" representedClassName="PageVisitManagedObject" syncable="YES">
<attribute name="date" attributeType="Date" usesScalarValueType="NO"/>
<relationship name="historyEntry" maxCount="1" deletionRule="Nullify" destinationEntity="BrowsingHistoryEntryManagedObject" inverseName="visits" inverseEntity="BrowsingHistoryEntryManagedObject"/>
</entity>
Expand Down
65 changes: 65 additions & 0 deletions Sources/History/CoreData/BrowsingHistoryEntryManagedObject.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// BrowsingHistoryEntryManagedObject.swift
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation
import CoreData

@objc(BrowsingHistoryEntryManagedObject)
public class BrowsingHistoryEntryManagedObject: NSManagedObject {

}

extension BrowsingHistoryEntryManagedObject {

@nonobjc public class func fetchRequest() -> NSFetchRequest<BrowsingHistoryEntryManagedObject> {
return NSFetchRequest<BrowsingHistoryEntryManagedObject>(entityName: "BrowsingHistoryEntryManagedObject")
}

@NSManaged public var blockedTrackingEntities: String?
@NSManaged public var failedToLoad: Bool
@NSManaged public var identifier: UUID?
@NSManaged public var lastVisit: Date?
@NSManaged public var numberOfTotalVisits: Int64
@NSManaged public var numberOfTrackersBlocked: Int64
@NSManaged public var title: String?
@NSManaged public var trackersFound: Bool
@NSManaged public var url: URL?
@NSManaged public var visits: NSSet?

}

// MARK: Generated accessors for visits
extension BrowsingHistoryEntryManagedObject {

@objc(addVisitsObject:)
@NSManaged public func addToVisits(_ value: PageVisitManagedObject)

@objc(removeVisitsObject:)
@NSManaged public func removeFromVisits(_ value: PageVisitManagedObject)

@objc(addVisits:)
@NSManaged public func addToVisits(_ values: NSSet)

@objc(removeVisits:)
@NSManaged public func removeFromVisits(_ values: NSSet)

}

extension BrowsingHistoryEntryManagedObject : Identifiable {

Check failure on line 63 in Sources/History/CoreData/BrowsingHistoryEntryManagedObject.swift

View workflow job for this annotation

GitHub Actions / Run SwiftLint

Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)

}
40 changes: 40 additions & 0 deletions Sources/History/CoreData/PageVisitManagedObject.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// PageVisitManagedObject.swift
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation
import CoreData

@objc(PageVisitManagedObject)
public class PageVisitManagedObject: NSManagedObject {

}

extension PageVisitManagedObject {

@nonobjc public class func fetchRequest() -> NSFetchRequest<PageVisitManagedObject> {
return NSFetchRequest<PageVisitManagedObject>(entityName: "PageVisitManagedObject")
}

@NSManaged public var date: Date?
@NSManaged public var historyEntry: BrowsingHistoryEntryManagedObject?

}

extension PageVisitManagedObject : Identifiable {

Check failure on line 38 in Sources/History/CoreData/PageVisitManagedObject.swift

View workflow job for this annotation

GitHub Actions / Run SwiftLint

Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)

}

0 comments on commit c1a8ea4

Please sign in to comment.