Skip to content

Commit 6fc9d2d

Browse files
authored
feat: add toCLLocation and toCLLocationCoordinate2D to ParseGeoPoint (#366)
feat: add toCLLocation and toCLLocationCoordinate2D properties to ParseGeoPoint
1 parent 5a2c5fd commit 6fc9d2d

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* _Contributing to this repo? Add info about your change here to be included in the next release_
77

88
__New features__
9+
- Add toCLLocation and toCLLocationCoordinate2D computed properties to ParseGeoPoint, deprecate toCLLocation() and toCLLocationCoordinate2D() ([#366](https://github.com/parse-community/Parse-Swift/pull/366)), thanks to [Corey Baker](https://github.com/cbaker6).
910
- Add query computed property to ParseObject ([#365](https://github.com/parse-community/Parse-Swift/pull/365)), thanks to [Corey Baker](https://github.com/cbaker6).
1011
- Add macCatalyst to SPM ([#363](https://github.com/parse-community/Parse-Swift/pull/363)), thanks to [Corey Baker](https://github.com/cbaker6).
1112
- Add includeAll computed property to Query and deprecate includeAll(). Add an order() method to Query that excepts a variadic list as input ([#362](https://github.com/parse-community/Parse-Swift/pull/362)), thanks to [Corey Baker](https://github.com/cbaker6).

Sources/ParseSwift/Extensions/Date.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import Foundation
1010

1111
// MARK: Date
1212
internal extension Date {
13-
func parseFormatted() -> String {
14-
return ParseCoding.dateFormatter.string(from: self)
13+
var parseFormatted: String {
14+
ParseCoding.dateFormatter.string(from: self)
1515
}
1616

1717
var parseRepresentation: [String: String] {
18-
return ["__type": "Date", "iso": parseFormatted()]
18+
["__type": "Date", "iso": parseFormatted]
1919
}
2020
}

Sources/ParseSwift/Types/ParseGeoPoint.swift

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,20 @@ extension ParseGeoPoint: CustomStringConvertible {
145145
// MARK: CoreLocation
146146
public extension ParseGeoPoint {
147147

148+
/**
149+
A `CLLocation` instance created from the current `ParseGeoPoint`.
150+
*/
151+
var toCLLocation: CLLocation {
152+
CLLocation(latitude: latitude, longitude: longitude)
153+
}
154+
155+
/**
156+
A `CLLocationCoordinate2D` instance created from the current `ParseGeoPoint`.
157+
*/
158+
var toCLLocationCoordinate2D: CLLocationCoordinate2D {
159+
CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
160+
}
161+
148162
/**
149163
Creates a new `ParseGeoPoint` instance for the given `CLLocation`, set to the location's coordinates.
150164
- parameter location: Instance of `CLLocation`, with set latitude and longitude.
@@ -168,21 +182,21 @@ public extension ParseGeoPoint {
168182
}
169183

170184
/**
171-
Creates a new `CLLocation` instance for the given `ParseGeoPoint`, set to the location's coordinates.
172-
- parameter geopoint: Instance of `ParseGeoPoint`, with set latitude and longitude.
185+
A `CLLocation` instance created from the current `ParseGeoPoint`.
173186
- returns: Returns a `CLLocation`.
174187
*/
175-
func toCLLocation() -> CLLocation {
176-
CLLocation(latitude: latitude, longitude: longitude)
188+
@available(*, deprecated, message: "Use the computed property instead by removing \"()\"")
189+
func toCLLocation(_ geoPoint: ParseGeoPoint? = nil) -> CLLocation {
190+
toCLLocation
177191
}
178192

179193
/**
180-
Creates a new `CLLocationCoordinate2D` instance for the given `ParseGeoPoint`, set to the location's coordinates.
181-
- parameter geopoint: Instance of `ParseGeoPoint`, with set latitude and longitude.
194+
A `CLLocationCoordinate2D` instance created from the current `ParseGeoPoint`.
182195
- returns: Returns a `CLLocationCoordinate2D`.
183196
*/
184-
func toCLLocationCoordinate2D() -> CLLocationCoordinate2D {
185-
CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
197+
@available(*, deprecated, message: "Use the computed property instead by removing \"()\"")
198+
func toCLLocationCoordinate2D(_ geoPoint: ParseGeoPoint? = nil) -> CLLocationCoordinate2D {
199+
toCLLocationCoordinate2D
186200
}
187201
}
188202
#endif

Sources/ParseSwift/Types/Query.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public struct Query<T>: Encodable, Equatable where T: ParseObject {
268268
- warning: This will be removed in ParseSwift 5.0.0 in favor of the `includeAll` computed property.
269269
- returns: The mutated instance of query for easy chaining.
270270
*/
271-
@available(*, deprecated, renamed: "includeAll")
271+
@available(*, deprecated, message: "Use the computed property instead by removing \"()\"")
272272
public func includeAll(_ keys: [String]? = nil) -> Query<T> {
273273
self.includeAll
274274
}

0 commit comments

Comments
 (0)