Commit 9ff9fa456e1b5ad556c6deca32de5c5491eafad0
Exists in
parentassistant
Merge branch 'parentassistant' of http://git.shunzhi.net/iosgroup/parentassistan…
…t into parentassistant
Showing
8 changed files
with
106 additions
and
13 deletions
Show diff stats
ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj
@@ -289,6 +289,7 @@ | @@ -289,6 +289,7 @@ | ||
289 | BF7A4C82204E338400460463 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; | 289 | BF7A4C82204E338400460463 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; |
290 | BF7A4C83204E338400460463 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; | 290 | BF7A4C83204E338400460463 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; |
291 | BFA74439207DB6EE00845D30 /* ActivationSchoolCardViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivationSchoolCardViewController.swift; sourceTree = "<group>"; }; | 291 | BFA74439207DB6EE00845D30 /* ActivationSchoolCardViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivationSchoolCardViewController.swift; sourceTree = "<group>"; }; |
292 | + BFA7443B2080869D00845D30 /* ParentAssistant 2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "ParentAssistant 2.xcdatamodel"; sourceTree = "<group>"; }; | ||
292 | BFBC06BB2063AE8800CCFAFF /* ZLaunchAd.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAd.swift; sourceTree = "<group>"; }; | 293 | BFBC06BB2063AE8800CCFAFF /* ZLaunchAd.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAd.swift; sourceTree = "<group>"; }; |
293 | BFBC06BC2063AE8800CCFAFF /* ZLaunchAdAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAdAnimation.swift; sourceTree = "<group>"; }; | 294 | BFBC06BC2063AE8800CCFAFF /* ZLaunchAdAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAdAnimation.swift; sourceTree = "<group>"; }; |
294 | BFBC06BD2063AE8800CCFAFF /* ZLaunchAdButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAdButton.swift; sourceTree = "<group>"; }; | 295 | BFBC06BD2063AE8800CCFAFF /* ZLaunchAdButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAdButton.swift; sourceTree = "<group>"; }; |
@@ -1284,7 +1285,7 @@ | @@ -1284,7 +1285,7 @@ | ||
1284 | "$(PROJECT_DIR)/Pods/NIMSDK_LITE/NIMSDK", | 1285 | "$(PROJECT_DIR)/Pods/NIMSDK_LITE/NIMSDK", |
1285 | ); | 1286 | ); |
1286 | INFOPLIST_FILE = "$(SRCROOT)/ParentAssistant/Supporting Files/Info.plist"; | 1287 | INFOPLIST_FILE = "$(SRCROOT)/ParentAssistant/Supporting Files/Info.plist"; |
1287 | - IPHONEOS_DEPLOYMENT_TARGET = 10.0; | 1288 | + IPHONEOS_DEPLOYMENT_TARGET = 9.0; |
1288 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | 1289 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; |
1289 | PRODUCT_BUNDLE_IDENTIFIER = net.shunzi.app.ParentAssistant; | 1290 | PRODUCT_BUNDLE_IDENTIFIER = net.shunzi.app.ParentAssistant; |
1290 | PRODUCT_NAME = "$(TARGET_NAME)"; | 1291 | PRODUCT_NAME = "$(TARGET_NAME)"; |
@@ -1314,7 +1315,7 @@ | @@ -1314,7 +1315,7 @@ | ||
1314 | "$(PROJECT_DIR)/Pods/NIMSDK_LITE/NIMSDK", | 1315 | "$(PROJECT_DIR)/Pods/NIMSDK_LITE/NIMSDK", |
1315 | ); | 1316 | ); |
1316 | INFOPLIST_FILE = "$(SRCROOT)/ParentAssistant/Supporting Files/Info.plist"; | 1317 | INFOPLIST_FILE = "$(SRCROOT)/ParentAssistant/Supporting Files/Info.plist"; |
1317 | - IPHONEOS_DEPLOYMENT_TARGET = 10.0; | 1318 | + IPHONEOS_DEPLOYMENT_TARGET = 9.0; |
1318 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | 1319 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; |
1319 | PRODUCT_BUNDLE_IDENTIFIER = net.shunzi.app.ParentAssistant; | 1320 | PRODUCT_BUNDLE_IDENTIFIER = net.shunzi.app.ParentAssistant; |
1320 | PRODUCT_NAME = "$(TARGET_NAME)"; | 1321 | PRODUCT_NAME = "$(TARGET_NAME)"; |
@@ -1395,9 +1396,10 @@ | @@ -1395,9 +1396,10 @@ | ||
1395 | BF7A4C3A204CD55300460463 /* ParentAssistant.xcdatamodeld */ = { | 1396 | BF7A4C3A204CD55300460463 /* ParentAssistant.xcdatamodeld */ = { |
1396 | isa = XCVersionGroup; | 1397 | isa = XCVersionGroup; |
1397 | children = ( | 1398 | children = ( |
1399 | + BFA7443B2080869D00845D30 /* ParentAssistant 2.xcdatamodel */, | ||
1398 | BF7A4C3B204CD55300460463 /* ParentAssistant.xcdatamodel */, | 1400 | BF7A4C3B204CD55300460463 /* ParentAssistant.xcdatamodel */, |
1399 | ); | 1401 | ); |
1400 | - currentVersion = BF7A4C3B204CD55300460463 /* ParentAssistant.xcdatamodel */; | 1402 | + currentVersion = BFA7443B2080869D00845D30 /* ParentAssistant 2.xcdatamodel */; |
1401 | path = ParentAssistant.xcdatamodeld; | 1403 | path = ParentAssistant.xcdatamodeld; |
1402 | sourceTree = "<group>"; | 1404 | sourceTree = "<group>"; |
1403 | versionGroupType = wrapper.xcdatamodel; | 1405 | versionGroupType = wrapper.xcdatamodel; |
ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/jun.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
ParentAssistant/ParentAssistant/AppDelegate.swift
@@ -201,11 +201,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | @@ -201,11 +201,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | ||
201 | func applicationWillTerminate(_ application: UIApplication) { | 201 | func applicationWillTerminate(_ application: UIApplication) { |
202 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | 202 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. |
203 | // Saves changes in the application's managed object context before the application terminates. | 203 | // Saves changes in the application's managed object context before the application terminates. |
204 | - self.saveContext() | 204 | + if #available(iOS 10.0, *) { |
205 | + self.saveContext() | ||
206 | + } else { | ||
207 | + // Fallback on earlier versions | ||
208 | + } | ||
205 | } | 209 | } |
206 | 210 | ||
207 | // MARK: - Core Data stack | 211 | // MARK: - Core Data stack |
208 | 212 | ||
213 | + @available(iOS 10.0, *) | ||
209 | lazy var persistentContainer: NSPersistentContainer = { | 214 | lazy var persistentContainer: NSPersistentContainer = { |
210 | /* | 215 | /* |
211 | The persistent container for the application. This implementation | 216 | The persistent container for the application. This implementation |
@@ -232,9 +237,47 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | @@ -232,9 +237,47 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | ||
232 | }) | 237 | }) |
233 | return container | 238 | return container |
234 | }() | 239 | }() |
235 | - | 240 | + |
241 | + lazy var applicationDocumentsDirectory: URL = { | ||
242 | + let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) | ||
243 | + return urls[urls.count-1] | ||
244 | + }() | ||
245 | + | ||
246 | + lazy var managedObjectModel: NSManagedObjectModel = { | ||
247 | + let modelURL = Bundle.main.url(forResource: "ParentAssistant", withExtension: "momd")! | ||
248 | + return NSManagedObjectModel(contentsOf: modelURL)! | ||
249 | + }() | ||
250 | + | ||
251 | + lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator = { | ||
252 | + let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel) | ||
253 | + let url = self.applicationDocumentsDirectory.appendingPathComponent("ParentAssistant.sqlite") | ||
254 | + var failureReason = "There was an error creating or loading the application's saved data." | ||
255 | + do { | ||
256 | + try coordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: url, options: nil) | ||
257 | + } catch { | ||
258 | + // Report any error we got. | ||
259 | + var dict = [String: AnyObject]() | ||
260 | + dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data" as AnyObject? | ||
261 | + dict[NSLocalizedFailureReasonErrorKey] = failureReason as AnyObject? | ||
262 | + | ||
263 | + dict[NSUnderlyingErrorKey] = error as NSError | ||
264 | + let wrappedError = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict) | ||
265 | + NSLog("Unresolved error \(wrappedError), \(wrappedError.userInfo)") | ||
266 | + abort() | ||
267 | + } | ||
268 | + | ||
269 | + return coordinator | ||
270 | + }() | ||
271 | + | ||
272 | + lazy var managedObjectContext: NSManagedObjectContext = { | ||
273 | + let coordinator = self.persistentStoreCoordinator | ||
274 | + var managedObjectContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType) | ||
275 | + managedObjectContext.persistentStoreCoordinator = coordinator | ||
276 | + return managedObjectContext | ||
277 | + }() | ||
236 | // MARK: - Core Data Saving support | 278 | // MARK: - Core Data Saving support |
237 | 279 | ||
280 | + @available(iOS 10.0, *) | ||
238 | func saveContext () { | 281 | func saveContext () { |
239 | let context = persistentContainer.viewContext | 282 | let context = persistentContainer.viewContext |
240 | if context.hasChanges { | 283 | if context.hasChanges { |
ParentAssistant/ParentAssistant/Classes/controllers/main/TabBarController.swift
@@ -46,8 +46,12 @@ class TabBarController: UITabBarController { | @@ -46,8 +46,12 @@ class TabBarController: UITabBarController { | ||
46 | if UIApplication.appVersion() < version{ | 46 | if UIApplication.appVersion() < version{ |
47 | let alert = UIAlertController(title: "发现新版本", message: dataInformatica["releaseNotes"]! as? String, preferredStyle: .alert) | 47 | let alert = UIAlertController(title: "发现新版本", message: dataInformatica["releaseNotes"]! as? String, preferredStyle: .alert) |
48 | alert.addAction(UIAlertAction(title: "前往更新", style: .default, handler: { (action) in | 48 | alert.addAction(UIAlertAction(title: "前往更新", style: .default, handler: { (action) in |
49 | - // UIApplication.shared.openURL(URL(string: "itms-apps://itunes.apple.com/app/id1271291794")!) | ||
50 | - UIApplication.shared.open(URL(string: "itms-apps://itunes.apple.com/app/id1357945086")!, options: [:], completionHandler: nil) | 49 | + if #available(iOS 10.0, *) { |
50 | + UIApplication.shared.open(URL(string: "itms-apps://itunes.apple.com/app/id1357945086")!, options: [:], completionHandler: nil) | ||
51 | + } else { | ||
52 | + // Fallback on earlier versions | ||
53 | + UIApplication.shared.openURL(URL(string: "itms-apps://itunes.apple.com/app/id1271291794")!) | ||
54 | + } | ||
51 | })) | 55 | })) |
52 | alert.addAction(UIAlertAction(title: "以后再说", style: .cancel, handler: { (action) in | 56 | alert.addAction(UIAlertAction(title: "以后再说", style: .cancel, handler: { (action) in |
53 | 57 |
ParentAssistant/ParentAssistant/Classes/controllers/my/Model/MessageManager.swift
@@ -12,7 +12,13 @@ extension NSManagedObject { | @@ -12,7 +12,13 @@ extension NSManagedObject { | ||
12 | 12 | ||
13 | static func creatWith(identifier:String)->NSManagedObject { | 13 | static func creatWith(identifier:String)->NSManagedObject { |
14 | //获取管理的数据上下文 对象 | 14 | //获取管理的数据上下文 对象 |
15 | - let context = appDelegate.persistentContainer.viewContext | 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 | + } | ||
16 | //创建对象 | 22 | //创建对象 |
17 | let obj = NSEntityDescription.insertNewObject(forEntityName: identifier,into: context) | 23 | let obj = NSEntityDescription.insertNewObject(forEntityName: identifier,into: context) |
18 | return obj | 24 | return obj |
@@ -20,7 +26,13 @@ extension NSManagedObject { | @@ -20,7 +26,13 @@ extension NSManagedObject { | ||
20 | //查询数据操作 | 26 | //查询数据操作 |
21 | static func fetchModel(identifier:String,ownid:String)->[Any]{ | 27 | static func fetchModel(identifier:String,ownid:String)->[Any]{ |
22 | //获取管理的数据上下文 对象 | 28 | //获取管理的数据上下文 对象 |
23 | - let context = appDelegate.persistentContainer.viewContext | 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 | + } | ||
24 | //声明数据的请求 | 36 | //声明数据的请求 |
25 | let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier) | 37 | let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier) |
26 | fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] | 38 | fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] |
@@ -43,7 +55,13 @@ extension NSManagedObject { | @@ -43,7 +55,13 @@ extension NSManagedObject { | ||
43 | //查询数据操作 | 55 | //查询数据操作 |
44 | static func fetchAllUnReadModel(identifier:String,ownid:String)->[Any]{ | 56 | static func fetchAllUnReadModel(identifier:String,ownid:String)->[Any]{ |
45 | //获取管理的数据上下文 对象 | 57 | //获取管理的数据上下文 对象 |
46 | - let context = appDelegate.persistentContainer.viewContext | 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 | + } | ||
47 | //声明数据的请求 | 65 | //声明数据的请求 |
48 | let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier) | 66 | let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier) |
49 | fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] | 67 | fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] |
@@ -66,7 +84,13 @@ extension NSManagedObject { | @@ -66,7 +84,13 @@ extension NSManagedObject { | ||
66 | 84 | ||
67 | func save(){ | 85 | func save(){ |
68 | //获取管理的数据上下文 对象 | 86 | //获取管理的数据上下文 对象 |
69 | - let context = appDelegate.persistentContainer.viewContext | 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 | + } | ||
70 | //保存 | 94 | //保存 |
71 | do { | 95 | do { |
72 | try context.save() | 96 | try context.save() |
@@ -77,7 +101,13 @@ extension NSManagedObject { | @@ -77,7 +101,13 @@ extension NSManagedObject { | ||
77 | } | 101 | } |
78 | func delete(){ | 102 | func delete(){ |
79 | //获取管理的数据上下文 对象 | 103 | //获取管理的数据上下文 对象 |
80 | - let context = appDelegate.persistentContainer.viewContext | 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 | + } | ||
81 | context.delete(self) | 111 | context.delete(self) |
82 | //重新保存-更新到数据库 | 112 | //重新保存-更新到数据库 |
83 | save() | 113 | save() |
ParentAssistant/ParentAssistant/NIM/YXMessageManager.swift
@@ -113,6 +113,7 @@ class YXMessageManager: NSObject,NIMLoginManagerDelegate,NIMSystemNotificationMa | @@ -113,6 +113,7 @@ class YXMessageManager: NSObject,NIMLoginManagerDelegate,NIMSystemNotificationMa | ||
113 | }else if info["type"].stringValue=="ordermess"{//订购通知 | 113 | }else if info["type"].stringValue=="ordermess"{//订购通知 |
114 | let attachItem = NSManagedObject.creatWith(identifier: "Message") as! Message | 114 | let attachItem = NSManagedObject.creatWith(identifier: "Message") as! Message |
115 | attachItem.date=Date(timeIntervalSince1970: notification.timestamp) | 115 | attachItem.date=Date(timeIntervalSince1970: notification.timestamp) |
116 | + attachItem.type = "ordermess" | ||
116 | attachItem.content = info["content"].stringValue | 117 | attachItem.content = info["content"].stringValue |
117 | attachItem.ownId = AccountManager.shared.userid | 118 | attachItem.ownId = AccountManager.shared.userid |
118 | attachItem.save() | 119 | attachItem.save() |
ParentAssistant/ParentAssistant/ParentAssistant.xcdatamodeld/.xccurrentversion
@@ -3,6 +3,6 @@ | @@ -3,6 +3,6 @@ | ||
3 | <plist version="1.0"> | 3 | <plist version="1.0"> |
4 | <dict> | 4 | <dict> |
5 | <key>_XCCurrentVersionName</key> | 5 | <key>_XCCurrentVersionName</key> |
6 | - <string>ParentAssistant.xcdatamodel</string> | 6 | + <string>ParentAssistant 2.xcdatamodel</string> |
7 | </dict> | 7 | </dict> |
8 | </plist> | 8 | </plist> |
ParentAssistant/ParentAssistant/ParentAssistant.xcdatamodeld/ParentAssistant 2.xcdatamodel/contents
0 → 100644
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
2 | +<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="13772" systemVersion="16G29" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> | ||
3 | + <entity name="Message" representedClassName="Message" syncable="YES" codeGenerationType="class"> | ||
4 | + <attribute name="content" optional="YES" attributeType="String" syncable="YES"/> | ||
5 | + <attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/> | ||
6 | + <attribute name="isReaded" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/> | ||
7 | + <attribute name="ownId" optional="YES" attributeType="String" syncable="YES"/> | ||
8 | + <attribute name="type" optional="YES" attributeType="String" syncable="YES"/> | ||
9 | + </entity> | ||
10 | + <elements> | ||
11 | + <element name="Message" positionX="-63" positionY="-18" width="128" height="120"/> | ||
12 | + </elements> | ||
13 | +</model> | ||
0 | \ No newline at end of file | 14 | \ No newline at end of file |