integrated local db
This commit is contained in:
15
UserClicks+CoreDataClass.swift
Normal file
15
UserClicks+CoreDataClass.swift
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// UserClicks+CoreDataClass.swift
|
||||
// WOKA
|
||||
//
|
||||
// Created by MacBook Pro on 05/08/24.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
@objc(UserClicks)
|
||||
public class UserClicks: NSManagedObject {
|
||||
|
||||
}
|
||||
28
UserClicks+CoreDataProperties.swift
Normal file
28
UserClicks+CoreDataProperties.swift
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// UserClicks+CoreDataProperties.swift
|
||||
// WOKA
|
||||
//
|
||||
// Created by MacBook Pro on 05/08/24.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
|
||||
extension UserClicks {
|
||||
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<UserClicks> {
|
||||
return NSFetchRequest<UserClicks>(entityName: "UserClicks")
|
||||
}
|
||||
|
||||
@NSManaged public var click_counts: Int64
|
||||
@NSManaged public var category_id: Int64
|
||||
@NSManaged public var post_id: Int64
|
||||
@NSManaged public var post_type: Int64
|
||||
|
||||
}
|
||||
|
||||
extension UserClicks : Identifiable {
|
||||
|
||||
}
|
||||
@@ -141,6 +141,10 @@
|
||||
52A981D82C1B0E27000E0BEC /* FavouriteCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 52A981D62C1B0E27000E0BEC /* FavouriteCell.xib */; };
|
||||
52AC2D252C295A7900337473 /* TeaserDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52AC2D242C295A7900337473 /* TeaserDM.swift */; };
|
||||
52AC2D272C29791500337473 /* JWPlayerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52AC2D262C29791500337473 /* JWPlayerManager.swift */; };
|
||||
52ACC1222C610C5900791528 /* WOKA.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1202C610C5900791528 /* WOKA.xcdatamodeld */; };
|
||||
52ACC1252C610CBC00791528 /* UserClicks+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1232C610CBC00791528 /* UserClicks+CoreDataClass.swift */; };
|
||||
52ACC1262C610CBC00791528 /* UserClicks+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1242C610CBC00791528 /* UserClicks+CoreDataProperties.swift */; };
|
||||
52ACC12A2C610EC900791528 /* PersistentStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1292C610EC900791528 /* PersistentStorage.swift */; };
|
||||
52AECA802C08BCB6004A7579 /* PlayerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52AECA7F2C08BCB6004A7579 /* PlayerVC.swift */; };
|
||||
52AF71EE2C36AD3100BC5972 /* GamesListVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52AF71ED2C36AD3100BC5972 /* GamesListVM.swift */; };
|
||||
52AF71F02C36B29A00BC5972 /* GamesListDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52AF71EF2C36B29A00BC5972 /* GamesListDM.swift */; };
|
||||
@@ -489,6 +493,10 @@
|
||||
52A981D62C1B0E27000E0BEC /* FavouriteCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FavouriteCell.xib; sourceTree = "<group>"; };
|
||||
52AC2D242C295A7900337473 /* TeaserDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeaserDM.swift; sourceTree = "<group>"; };
|
||||
52AC2D262C29791500337473 /* JWPlayerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWPlayerManager.swift; sourceTree = "<group>"; };
|
||||
52ACC1212C610C5900791528 /* WOKA.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WOKA.xcdatamodel; sourceTree = "<group>"; };
|
||||
52ACC1232C610CBC00791528 /* UserClicks+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserClicks+CoreDataClass.swift"; sourceTree = SOURCE_ROOT; };
|
||||
52ACC1242C610CBC00791528 /* UserClicks+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserClicks+CoreDataProperties.swift"; sourceTree = SOURCE_ROOT; };
|
||||
52ACC1292C610EC900791528 /* PersistentStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistentStorage.swift; sourceTree = "<group>"; };
|
||||
52AECA7F2C08BCB6004A7579 /* PlayerVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerVC.swift; sourceTree = "<group>"; };
|
||||
52AF71ED2C36AD3100BC5972 /* GamesListVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GamesListVM.swift; sourceTree = "<group>"; };
|
||||
52AF71EF2C36B29A00BC5972 /* GamesListDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GamesListDM.swift; sourceTree = "<group>"; };
|
||||
@@ -816,6 +824,8 @@
|
||||
523ED25C2BDA2BC700CFED02 /* WOKA */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
52ACC1232C610CBC00791528 /* UserClicks+CoreDataClass.swift */,
|
||||
52ACC1242C610CBC00791528 /* UserClicks+CoreDataProperties.swift */,
|
||||
5255C3FB2C5B67C90030BB22 /* WOKAFM */,
|
||||
527A2BD32C57D0B20080DF9B /* Address */,
|
||||
5259542C2BEA392A00191286 /* Alerts */,
|
||||
@@ -845,6 +855,8 @@
|
||||
9C535DC82C00C34000DA6DCD /* Theme */,
|
||||
52DAC6462C21761700E2F85B /* WebSeries */,
|
||||
9C834ED92C1C20EC00B29A9C /* WOKA.entitlements */,
|
||||
52ACC1202C610C5900791528 /* WOKA.xcdatamodeld */,
|
||||
52ACC1292C610EC900791528 /* PersistentStorage.swift */,
|
||||
);
|
||||
path = WOKA;
|
||||
sourceTree = "<group>";
|
||||
@@ -2178,6 +2190,7 @@
|
||||
9C27E16F2BDB866500EC1DA9 /* CellIdentifier.swift in Sources */,
|
||||
52BC3BF22C170264002FACA6 /* MoreVM.swift in Sources */,
|
||||
9CB3D08F2C37D0D60062869D /* KaraokeListingDM.swift in Sources */,
|
||||
52ACC12A2C610EC900791528 /* PersistentStorage.swift in Sources */,
|
||||
9CBE1B412C0F37B300CA6E61 /* DPDUIView+Extension.swift in Sources */,
|
||||
525861DE2C4FE7A100C33C79 /* CouponCell.swift in Sources */,
|
||||
9C27E1632BDB6F1900EC1DA9 /* AuthFunc.swift in Sources */,
|
||||
@@ -2283,6 +2296,8 @@
|
||||
9CB3D08D2C37CDD60062869D /* KaraokeListingVM.swift in Sources */,
|
||||
5222426A2BFC7AFC0085C632 /* SideMenuVC.swift in Sources */,
|
||||
527AC7012C182DCE00434FB7 /* TimeStringToSeconds.swift in Sources */,
|
||||
52ACC1252C610CBC00791528 /* UserClicks+CoreDataClass.swift in Sources */,
|
||||
52ACC1262C610CBC00791528 /* UserClicks+CoreDataProperties.swift in Sources */,
|
||||
9CBCB29D2BE4D6BB007D7934 /* LoginVM.swift in Sources */,
|
||||
52BBFCB42C5275E100F7D0D1 /* AddressListVM.swift in Sources */,
|
||||
524C42312C0499560016A11C /* NotificationCenterReloads.swift in Sources */,
|
||||
@@ -2310,6 +2325,7 @@
|
||||
529B0DD42C06156B00CFC54B /* LoginNavVC.swift in Sources */,
|
||||
52A981D72C1B0E27000E0BEC /* FavouriteCell.swift in Sources */,
|
||||
52BFB0652C5B5B4F0038D750 /* BlogsVC.swift in Sources */,
|
||||
52ACC1222C610C5900791528 /* WOKA.xcdatamodeld in Sources */,
|
||||
52C8B05F2BDA5AFA003B51D0 /* SplashVM.swift in Sources */,
|
||||
52C1A4E12C05B69F007BAA50 /* UIApplicationSwitchRoot.swift in Sources */,
|
||||
527A2BCC2C577F8A0080DF9B /* AnalyticsEventKeys.swift in Sources */,
|
||||
@@ -2809,6 +2825,20 @@
|
||||
productName = FirebasePerformance;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
|
||||
/* Begin XCVersionGroup section */
|
||||
52ACC1202C610C5900791528 /* WOKA.xcdatamodeld */ = {
|
||||
isa = XCVersionGroup;
|
||||
children = (
|
||||
52ACC1212C610C5900791528 /* WOKA.xcdatamodel */,
|
||||
);
|
||||
currentVersion = 52ACC1212C610C5900791528 /* WOKA.xcdatamodel */;
|
||||
name = WOKA.xcdatamodeld;
|
||||
path = /Users/macbookpro/Desktop/WOKA/WOKA/WOKA.xcdatamodeld;
|
||||
sourceTree = "<group>";
|
||||
versionGroupType = wrapper.xcdatamodel;
|
||||
};
|
||||
/* End XCVersionGroup section */
|
||||
};
|
||||
rootObject = 523ED2522BDA2BC700CFED02 /* Project object */;
|
||||
}
|
||||
|
||||
@@ -16,14 +16,6 @@ let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
||||
@main
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
// var window: UIWindow?
|
||||
//
|
||||
// var myOrientation: UIInterfaceOrientationMask = .portrait
|
||||
//
|
||||
// func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
|
||||
// return myOrientation
|
||||
// }
|
||||
|
||||
var window: UIWindow?
|
||||
var deviceOrientation = UIInterfaceOrientationMask.portrait
|
||||
|
||||
@@ -119,3 +111,4 @@ extension AppDelegate {
|
||||
SideMenuController.preferences.animation.revealDuration = 0.6
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ class SplashVM{
|
||||
}else{
|
||||
AuthFunc.shareInstance.setDefaultLanguage(language: .english)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Play initial sound
|
||||
|
||||
73
WOKA/PersistentStorage.swift
Normal file
73
WOKA/PersistentStorage.swift
Normal file
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// PersistentStorage.swift
|
||||
// WOKA
|
||||
//
|
||||
// Created by MacBook Pro on 05/08/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
/**
|
||||
Hey there, I hope you enjoyed the video, if you have any questions then please feel free to ask I will be happy to answer them.
|
||||
|
||||
Do share this with your iOS group on whatsapp or facebook or anyone who wants to learn iOS*/
|
||||
|
||||
final class PersistentStorage
|
||||
{
|
||||
|
||||
private init(){}
|
||||
static let shared = PersistentStorage()
|
||||
|
||||
// MARK: - Core Data stack
|
||||
|
||||
lazy var persistentContainer: NSPersistentContainer = {
|
||||
|
||||
let container = NSPersistentContainer(name: "WOKA")
|
||||
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
|
||||
if let error = error as NSError? {
|
||||
|
||||
fatalError("Unresolved errorsss \(error), \(error.userInfo)")
|
||||
}
|
||||
})
|
||||
return container
|
||||
}()
|
||||
|
||||
lazy var context = persistentContainer.viewContext
|
||||
// MARK: - Core Data Saving support
|
||||
|
||||
func saveContext() {
|
||||
if context.hasChanges {
|
||||
do {
|
||||
try context.save()
|
||||
} catch {
|
||||
let nserror = error as NSError
|
||||
fatalError("Unresolved errorsss \(nserror), \(nserror.userInfo)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func saveClicksCount(){
|
||||
let clicks = UserClicks(context: PersistentStorage.shared.context)
|
||||
clicks.post_type = 1
|
||||
clicks.post_id = 22
|
||||
clicks.category_id = 33
|
||||
clicks.click_counts = 100
|
||||
PersistentStorage.shared.saveContext()
|
||||
}
|
||||
|
||||
func getchClicksCount(){
|
||||
let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
|
||||
debugPrint(path[0])
|
||||
|
||||
do {
|
||||
guard let result = try PersistentStorage.shared.context.fetch(UserClicks.fetchRequest()) as? [UserClicks] else {return}
|
||||
result.forEach({debugPrint("sad", $0.click_counts)})
|
||||
|
||||
} catch let error
|
||||
{
|
||||
debugPrint(error)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,6 +46,7 @@ class ThemeOneVM{
|
||||
vc.nameLabel.setContentCompressionResistancePriority(.fittingSizeLevel, for: .horizontal)
|
||||
|
||||
handleBackground()
|
||||
|
||||
}
|
||||
|
||||
private func handleNotificationCenter(){
|
||||
|
||||
9
WOKA/WOKA.xcdatamodeld/WOKA.xcdatamodel/contents
Normal file
9
WOKA/WOKA.xcdatamodeld/WOKA.xcdatamodel/contents
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22758" systemVersion="23F79" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithSwiftData="YES" userDefinedModelVersionIdentifier="">
|
||||
<entity name="UserClicks" representedClassName="UserClicks" syncable="YES">
|
||||
<attribute name="category_id" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="click_counts" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="post_id" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="post_type" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
</entity>
|
||||
</model>
|
||||
Reference in New Issue
Block a user