diff --git a/AppMessage/AppMessage.xcodeproj/project.pbxproj b/AppMessage/AppMessage.xcodeproj/project.pbxproj index e929282..9e71b12 100755 --- a/AppMessage/AppMessage.xcodeproj/project.pbxproj +++ b/AppMessage/AppMessage.xcodeproj/project.pbxproj @@ -547,7 +547,7 @@ PROVISIONING_PROFILE = ""; SWIFT_OBJC_BRIDGING_HEADER = "AppMessage/AppMessage-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -570,7 +570,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SWIFT_OBJC_BRIDGING_HEADER = "AppMessage/AppMessage-Bridging-Header.h"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/AppMessage/AppMessage/Controlers/ChatViewController.swift b/AppMessage/AppMessage/Controlers/ChatViewController.swift index a13743f..52fb4f5 100755 --- a/AppMessage/AppMessage/Controlers/ChatViewController.swift +++ b/AppMessage/AppMessage/Controlers/ChatViewController.swift @@ -423,7 +423,7 @@ class ChatViewController: JSQMessagesViewController, UIActionSheetDelegate, Uzys } else { cell.textView!.textColor = UIColor.white } - cell.textView!.linkTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue : cell.textView!.textColor!, NSAttributedStringKey.underlineStyle.rawValue : NSUnderlineStyle.styleSingle.rawValue] + //cell.textView!.linkTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue : cell.textView!.textColor!, NSAttributedStringKey.underlineStyle.rawValue : NSUnderlineStyle.styleSingle.rawValue] } return cell } diff --git a/AppMessage/AppMessage/Controlers/LeftMenuViewController.swift b/AppMessage/AppMessage/Controlers/LeftMenuViewController.swift index f1d27e6..41d1669 100755 --- a/AppMessage/AppMessage/Controlers/LeftMenuViewController.swift +++ b/AppMessage/AppMessage/Controlers/LeftMenuViewController.swift @@ -144,9 +144,9 @@ class LeftMenuViewController: UIViewController, UITableViewDataSource, UITableVi // ------------------------------------------------------------------------ func connectToNews(_ retryCount: Double = 1) { - + let loc: CLLocation! = nil EVCloudData.publicDB.connect( - News(), predicate: NSPredicate(value: true), orderBy: Ascending(field: "Subject").Descending("creationDate"), filterId: "News_All", configureNotificationInfo: { notificationInfo in + News(), predicate: NSPredicate(value: true), orderBy: Distance(field: "", relativeLocation: loc).Ascending("Subject").Descending("creationDate"), filterId: "News_All", configureNotificationInfo: { notificationInfo in //notificationInfo.alertBody = "News update" notificationInfo.shouldSendContentAvailable = true // is already the default notificationInfo.alertLocalizationKey = "News: %1$@" diff --git a/EVCloudKitDao.podspec b/EVCloudKitDao.podspec index 8a05608..6eb0150 100755 --- a/EVCloudKitDao.podspec +++ b/EVCloudKitDao.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "EVCloudKitDao" - s.version = "3.3.3" + s.version = "3.5.0" s.summary = "iOS: Simplified access to Apple’s CloudKit" s.description = "Simplified access to Apple’s CloudKit using reflection and generics" diff --git a/Source/EVSort.swift b/Source/EVSort.swift index 31d004c..e4a2183 100755 --- a/Source/EVSort.swift +++ b/Source/EVSort.swift @@ -6,6 +6,8 @@ // import Foundation +import CoreLocation +import CloudKit /** Enum that will be used to specify the order @@ -23,6 +25,7 @@ open class OrderBy { var field: String = "" var direction: SortDirection = .descending var parent: OrderBy? + var sortDescriptor: NSSortDescriptor? = nil /** Convenience init for creating an order object with all the parameters @@ -36,6 +39,12 @@ open class OrderBy { self.field = field self.direction = direction self.parent = parent + self.sortDescriptor = NSSortDescriptor(key: field, ascending: (direction == .ascending)) + } + + public convenience init(sortDescriptor: NSSortDescriptor, parent: OrderBy? = nil) { + self.init() + self.sortDescriptor = sortDescriptor } /** @@ -60,6 +69,10 @@ open class OrderBy { return OrderBy(field: field, parent: self, direction: .descending) } + open func Distance(_ field: String, relativeLocation: CLLocation) -> OrderBy { + return OrderBy(sortDescriptor: CKLocationSortDescriptor(key: field, relativeLocation: relativeLocation), parent: self) + } + /** Build up an array of sortDescriptors @@ -67,7 +80,9 @@ open class OrderBy { */ open func sortDescriptors() -> [NSSortDescriptor] { var result: [NSSortDescriptor] = parent?.sortDescriptors() ?? [] - result.append( NSSortDescriptor(key: field, ascending: (direction == .ascending))) + if let sort = self.sortDescriptor { + result.append(sort) + } return result } } @@ -95,3 +110,10 @@ open class Descending: OrderBy { self.init(field: field, parent: nil, direction: .descending) } } + +// Just here so that we can use a nice name while ordering. +open class Distance: OrderBy { + public convenience required init(field: String, relativeLocation: CLLocation) { + self.init(sortDescriptor: CKLocationSortDescriptor(key: field, relativeLocation: relativeLocation), parent: nil) + } +} diff --git a/UnitTests/UnitTests.xcodeproj/xcshareddata/xcschemes/OSXTest.xcscheme b/UnitTests/UnitTests.xcodeproj/xcshareddata/xcschemes/OSXTest.xcscheme index 51a6740..b77a5e8 100755 --- a/UnitTests/UnitTests.xcodeproj/xcshareddata/xcschemes/OSXTest.xcscheme +++ b/UnitTests/UnitTests.xcodeproj/xcshareddata/xcschemes/OSXTest.xcscheme @@ -5,11 +5,28 @@ + + + + + + + + + + @@ -30,12 +56,22 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES"> + + + + @@ -45,6 +81,15 @@ savedToolIdentifier = "" useCustomWorkingDirectory = "NO" debugDocumentVersioning = "YES"> + + + +