Commit 85f14aeeb85e83524f13b32a5c3d48cf10de4178
1 parent
c33c3ada
Exists in
parentassistant
no message
Showing
3 changed files
with
122 additions
and
122 deletions
Show diff stats
ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj
... | ... | @@ -78,7 +78,6 @@ |
78 | 78 | BF38847C205CDE1B00A240EF /* JS.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF38847B205CDE1B00A240EF /* JS.storyboard */; }; |
79 | 79 | BF38847E205CDE2D00A240EF /* JSViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF38847D205CDE2D00A240EF /* JSViewController.swift */; }; |
80 | 80 | BF388480205CDFBE00A240EF /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF38847F205CDFBE00A240EF /* WebKit.framework */; }; |
81 | - BF388482205F5BC800A240EF /* MessageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF388481205F5BC800A240EF /* MessageManager.swift */; }; | |
82 | 81 | BF3B8298204FC80D002078EA /* UMCommon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF3B8297204FC80D002078EA /* UMCommon.framework */; }; |
83 | 82 | BF3B82A02050CC8B002078EA /* ReportHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3B829F2050CC8B002078EA /* ReportHeaderView.swift */; }; |
84 | 83 | BF406CD62057B03A000A6681 /* MessageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CD52057B03A000A6681 /* MessageViewController.swift */; }; |
... | ... | @@ -118,6 +117,7 @@ |
118 | 117 | BF7A4C86204E338500460463 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF7A4C81204E338400460463 /* Main.storyboard */; }; |
119 | 118 | BF7A4C87204E338500460463 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = BF7A4C83204E338400460463 /* Info.plist */; }; |
120 | 119 | BFA7443A207DB6EE00845D30 /* ActivationSchoolCardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFA74439207DB6EE00845D30 /* ActivationSchoolCardViewController.swift */; }; |
120 | + BFA7446C208193D300845D30 /* MessageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFA7446B208193D300845D30 /* MessageManager.swift */; }; | |
121 | 121 | BFBC06C52063AE8900CCFAFF /* ZLaunchAd.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBC06BB2063AE8800CCFAFF /* ZLaunchAd.swift */; }; |
122 | 122 | BFBC06C62063AE8900CCFAFF /* ZLaunchAdAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBC06BC2063AE8800CCFAFF /* ZLaunchAdAnimation.swift */; }; |
123 | 123 | BFBC06C72063AE8900CCFAFF /* ZLaunchAdButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBC06BD2063AE8800CCFAFF /* ZLaunchAdButton.swift */; }; |
... | ... | @@ -244,7 +244,6 @@ |
244 | 244 | BF38847B205CDE1B00A240EF /* JS.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = JS.storyboard; sourceTree = "<group>"; }; |
245 | 245 | BF38847D205CDE2D00A240EF /* JSViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSViewController.swift; sourceTree = "<group>"; }; |
246 | 246 | BF38847F205CDFBE00A240EF /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; |
247 | - BF388481205F5BC800A240EF /* MessageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageManager.swift; sourceTree = "<group>"; }; | |
248 | 247 | BF3B8297204FC80D002078EA /* UMCommon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UMCommon.framework; path = Pods/UMCCommon/UMCommon.framework; sourceTree = "<group>"; }; |
249 | 248 | BF3B829F2050CC8B002078EA /* ReportHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportHeaderView.swift; sourceTree = "<group>"; }; |
250 | 249 | BF406CD52057B03A000A6681 /* MessageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageViewController.swift; sourceTree = "<group>"; }; |
... | ... | @@ -290,6 +289,7 @@ |
290 | 289 | BF7A4C83204E338400460463 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; |
291 | 290 | BFA74439207DB6EE00845D30 /* ActivationSchoolCardViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivationSchoolCardViewController.swift; sourceTree = "<group>"; }; |
292 | 291 | BFA7443B2080869D00845D30 /* ParentAssistant 2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "ParentAssistant 2.xcdatamodel"; sourceTree = "<group>"; }; |
292 | + BFA7446B208193D300845D30 /* MessageManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageManager.swift; sourceTree = "<group>"; }; | |
293 | 293 | BFBC06BB2063AE8800CCFAFF /* ZLaunchAd.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAd.swift; sourceTree = "<group>"; }; |
294 | 294 | BFBC06BC2063AE8800CCFAFF /* ZLaunchAdAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAdAnimation.swift; sourceTree = "<group>"; }; |
295 | 295 | BFBC06BD2063AE8800CCFAFF /* ZLaunchAdButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAdButton.swift; sourceTree = "<group>"; }; |
... | ... | @@ -486,6 +486,7 @@ |
486 | 486 | ADE33B302062202300BEA6E6 /* Macro.swift */, |
487 | 487 | BF5D1669204E675C00274489 /* account.swift */, |
488 | 488 | BF5D166B204E6A0300274489 /* network.swift */, |
489 | + BFA7446B208193D300845D30 /* MessageManager.swift */, | |
489 | 490 | 599365282052553900C8B371 /* pinyin.c */, |
490 | 491 | 599365292052553900C8B371 /* pinyin.h */, |
491 | 492 | ); |
... | ... | @@ -745,7 +746,6 @@ |
745 | 746 | BFCED88A20528DE700055373 /* MyViewControllerModel.swift */, |
746 | 747 | BF406CD92057BEB8000A6681 /* OrderDetailModel.swift */, |
747 | 748 | BF388468205A4DE900A240EF /* StudentClassInfo.swift */, |
748 | - BF388481205F5BC800A240EF /* MessageManager.swift */, | |
749 | 749 | ); |
750 | 750 | path = Model; |
751 | 751 | sourceTree = "<group>"; |
... | ... | @@ -1052,7 +1052,6 @@ |
1052 | 1052 | 599364ED204E62E700C8B371 /* InformationViewController.swift in Sources */, |
1053 | 1053 | ADC9AB72207C55CE00348EF1 /* GrowViewController.swift in Sources */, |
1054 | 1054 | 5980BF692061048A00F4A35E /* LZCityPickerView.m in Sources */, |
1055 | - BF388482205F5BC800A240EF /* MessageManager.swift in Sources */, | |
1056 | 1055 | 5980BF682061048A00F4A35E /* LZCityPickerController.m in Sources */, |
1057 | 1056 | AD198173207D9FB4009AB8B5 /* ProgramCheckViewController.swift in Sources */, |
1058 | 1057 | BFCED88B20528DE700055373 /* MyViewControllerModel.swift in Sources */, |
... | ... | @@ -1091,6 +1090,7 @@ |
1091 | 1090 | AD64A2C0207F289400B25E80 /* ProgramVacateTableViewCell.swift in Sources */, |
1092 | 1091 | AD64A2C3207F28CF00B25E80 /* ProgramVacateBodyTableViewCell.swift in Sources */, |
1093 | 1092 | 599364EA204E62E700C8B371 /* ChannelViewController.swift in Sources */, |
1093 | + BFA7446C208193D300845D30 /* MessageManager.swift in Sources */, | |
1094 | 1094 | BF406CDE2057C537000A6681 /* OrderDetailTableViewCell.swift in Sources */, |
1095 | 1095 | BFEAAAC7205257460072FAAF /* LXCalenderCell.m in Sources */, |
1096 | 1096 | BFBC06CC2063AE8900CCFAFF /* ZLaunchAdWindow.swift in Sources */, | ... | ... |
ParentAssistant/ParentAssistant/Classes/controllers/my/Model/MessageManager.swift
... | ... | @@ -1,118 +0,0 @@ |
1 | -// | |
2 | -// MessageManager.swift | |
3 | -// ParentAssistant | |
4 | -// | |
5 | -// Created by 葛建军 on 2018/3/19. | |
6 | -// Copyright © 2018年 HANGZHOUTEAM. All rights reserved. | |
7 | -// | |
8 | - | |
9 | -import UIKit | |
10 | -import CoreData | |
11 | -extension NSManagedObject { | |
12 | - | |
13 | - static func creatWith(identifier:String)->NSManagedObject { | |
14 | - //获取管理的数据上下文 对象 | |
15 | - var context:NSManagedObjectContext! | |
16 | - if #available(iOS 10.0, *) { | |
17 | - context = appDelegate.persistentContainer.viewContext | |
18 | - } else { | |
19 | - // Fallback on earlier versions | |
20 | - context = appDelegate.managedObjectContext | |
21 | - } | |
22 | - //创建对象 | |
23 | - let obj = NSEntityDescription.insertNewObject(forEntityName: identifier,into: context) | |
24 | - return obj | |
25 | - } | |
26 | - //查询数据操作 | |
27 | - static func fetchModel(identifier:String,ownid:String)->[Any]{ | |
28 | - //获取管理的数据上下文 对象 | |
29 | - var context:NSManagedObjectContext! | |
30 | - if #available(iOS 10.0, *) { | |
31 | - context = appDelegate.persistentContainer.viewContext | |
32 | - } else { | |
33 | - // Fallback on earlier versions | |
34 | - context = appDelegate.managedObjectContext | |
35 | - } | |
36 | - //声明数据的请求 | |
37 | - let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier) | |
38 | - fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] | |
39 | -// fetchRequest.fetchLimit = 10 //限定查询结果的数量 | |
40 | - fetchRequest.fetchOffset = 0 //查询的偏移量 | |
41 | - | |
42 | - //设置查询条件 | |
43 | - let predicate = NSPredicate(format: "ownId = %@", ownid) | |
44 | - fetchRequest.predicate = predicate | |
45 | - | |
46 | - //查询操作 | |
47 | - do { | |
48 | - let fetchedObjects = try context.fetch(fetchRequest) | |
49 | - return fetchedObjects | |
50 | - } | |
51 | - catch { | |
52 | - fatalError("不能查询:\(error)") | |
53 | - } | |
54 | - } | |
55 | - //查询数据操作 | |
56 | - static func fetchAllUnReadModel(identifier:String,ownid:String)->[Any]{ | |
57 | - //获取管理的数据上下文 对象 | |
58 | - var context:NSManagedObjectContext! | |
59 | - if #available(iOS 10.0, *) { | |
60 | - context = appDelegate.persistentContainer.viewContext | |
61 | - } else { | |
62 | - // Fallback on earlier versions | |
63 | - context = appDelegate.managedObjectContext | |
64 | - } | |
65 | - //声明数据的请求 | |
66 | - let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier) | |
67 | - fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] | |
68 | - // fetchRequest.fetchLimit = 10 //限定查询结果的数量 | |
69 | - fetchRequest.fetchOffset = 0 //查询的偏移量 | |
70 | - | |
71 | - //设置查询条件 | |
72 | - let predicate = NSPredicate(format: "ownId = %@ and isReaded == %@", ownid,false as CVarArg) | |
73 | - fetchRequest.predicate = predicate | |
74 | - | |
75 | - //查询操作 | |
76 | - do { | |
77 | - let fetchedObjects = try context.fetch(fetchRequest) | |
78 | - return fetchedObjects | |
79 | - } | |
80 | - catch { | |
81 | - fatalError("不能查询:\(error)") | |
82 | - } | |
83 | - } | |
84 | - | |
85 | - func save(){ | |
86 | - //获取管理的数据上下文 对象 | |
87 | - var context:NSManagedObjectContext! | |
88 | - if #available(iOS 10.0, *) { | |
89 | - context = appDelegate.persistentContainer.viewContext | |
90 | - } else { | |
91 | - // Fallback on earlier versions | |
92 | - context = appDelegate.managedObjectContext | |
93 | - } | |
94 | - //保存 | |
95 | - do { | |
96 | - try context.save() | |
97 | - print("保存成功!") | |
98 | - } catch { | |
99 | - fatalError("不能保存:\(error)") | |
100 | - } | |
101 | - } | |
102 | - func delete(){ | |
103 | - //获取管理的数据上下文 对象 | |
104 | - var context:NSManagedObjectContext! | |
105 | - if #available(iOS 10.0, *) { | |
106 | - context = appDelegate.persistentContainer.viewContext | |
107 | - } else { | |
108 | - // Fallback on earlier versions | |
109 | - context = appDelegate.managedObjectContext | |
110 | - } | |
111 | - context.delete(self) | |
112 | - //重新保存-更新到数据库 | |
113 | - save() | |
114 | - } | |
115 | -} | |
116 | -class MessageNotification: NSObject { | |
117 | - static let receiveMessage = "YXReceiveMessage" | |
118 | -} |
ParentAssistant/ParentAssistant/Classes/util/MessageManager.swift
0 → 100644
... | ... | @@ -0,0 +1,118 @@ |
1 | +// | |
2 | +// MessageManager.swift | |
3 | +// ParentAssistant | |
4 | +// | |
5 | +// Created by 葛建军 on 2018/3/19. | |
6 | +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved. | |
7 | +// | |
8 | + | |
9 | +import UIKit | |
10 | +import CoreData | |
11 | +extension NSManagedObject { | |
12 | + | |
13 | + static func creatWith(identifier:String)->NSManagedObject { | |
14 | + //获取管理的数据上下文 对象 | |
15 | + var context:NSManagedObjectContext! | |
16 | + if #available(iOS 10.0, *) { | |
17 | + context = appDelegate.persistentContainer.viewContext | |
18 | + } else { | |
19 | + // Fallback on earlier versions | |
20 | + context = appDelegate.managedObjectContext | |
21 | + } | |
22 | + //创建对象 | |
23 | + let obj = NSEntityDescription.insertNewObject(forEntityName: identifier,into: context) | |
24 | + return obj | |
25 | + } | |
26 | + //查询数据操作 | |
27 | + static func fetchModel(identifier:String,ownid:String)->[Any]{ | |
28 | + //获取管理的数据上下文 对象 | |
29 | + var context:NSManagedObjectContext! | |
30 | + if #available(iOS 10.0, *) { | |
31 | + context = appDelegate.persistentContainer.viewContext | |
32 | + } else { | |
33 | + // Fallback on earlier versions | |
34 | + context = appDelegate.managedObjectContext | |
35 | + } | |
36 | + //声明数据的请求 | |
37 | + let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier) | |
38 | + fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] | |
39 | +// fetchRequest.fetchLimit = 10 //限定查询结果的数量 | |
40 | + fetchRequest.fetchOffset = 0 //查询的偏移量 | |
41 | + | |
42 | + //设置查询条件 | |
43 | + let predicate = NSPredicate(format: "ownId = %@", ownid) | |
44 | + fetchRequest.predicate = predicate | |
45 | + | |
46 | + //查询操作 | |
47 | + do { | |
48 | + let fetchedObjects = try context.fetch(fetchRequest) | |
49 | + return fetchedObjects | |
50 | + } | |
51 | + catch { | |
52 | + fatalError("不能查询:\(error)") | |
53 | + } | |
54 | + } | |
55 | + //查询数据操作 | |
56 | + static func fetchAllUnReadModel(identifier:String,ownid:String)->[Any]{ | |
57 | + //获取管理的数据上下文 对象 | |
58 | + var context:NSManagedObjectContext! | |
59 | + if #available(iOS 10.0, *) { | |
60 | + context = appDelegate.persistentContainer.viewContext | |
61 | + } else { | |
62 | + // Fallback on earlier versions | |
63 | + context = appDelegate.managedObjectContext | |
64 | + } | |
65 | + //声明数据的请求 | |
66 | + let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier) | |
67 | + fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] | |
68 | + // fetchRequest.fetchLimit = 10 //限定查询结果的数量 | |
69 | + fetchRequest.fetchOffset = 0 //查询的偏移量 | |
70 | + | |
71 | + //设置查询条件 | |
72 | + let predicate = NSPredicate(format: "ownId = %@ and isReaded == %@", ownid,false as CVarArg) | |
73 | + fetchRequest.predicate = predicate | |
74 | + | |
75 | + //查询操作 | |
76 | + do { | |
77 | + let fetchedObjects = try context.fetch(fetchRequest) | |
78 | + return fetchedObjects | |
79 | + } | |
80 | + catch { | |
81 | + fatalError("不能查询:\(error)") | |
82 | + } | |
83 | + } | |
84 | + | |
85 | + func save(){ | |
86 | + //获取管理的数据上下文 对象 | |
87 | + var context:NSManagedObjectContext! | |
88 | + if #available(iOS 10.0, *) { | |
89 | + context = appDelegate.persistentContainer.viewContext | |
90 | + } else { | |
91 | + // Fallback on earlier versions | |
92 | + context = appDelegate.managedObjectContext | |
93 | + } | |
94 | + //保存 | |
95 | + do { | |
96 | + try context.save() | |
97 | + print("保存成功!") | |
98 | + } catch { | |
99 | + fatalError("不能保存:\(error)") | |
100 | + } | |
101 | + } | |
102 | + func delete(){ | |
103 | + //获取管理的数据上下文 对象 | |
104 | + var context:NSManagedObjectContext! | |
105 | + if #available(iOS 10.0, *) { | |
106 | + context = appDelegate.persistentContainer.viewContext | |
107 | + } else { | |
108 | + // Fallback on earlier versions | |
109 | + context = appDelegate.managedObjectContext | |
110 | + } | |
111 | + context.delete(self) | |
112 | + //重新保存-更新到数据库 | |
113 | + save() | |
114 | + } | |
115 | +} | |
116 | +class MessageNotification: NSObject { | |
117 | + static let receiveMessage = "YXReceiveMessage" | |
118 | +} | ... | ... |