Skip to content

Commit 25ae335

Browse files
author
Clément Le Provost
committed
[refact] Use z_objc_ to prefix Objective-C specific properties
… instead of just `z_`. This should make it more obvious that they are not meant to be used from Swift.
1 parent 5715386 commit 25ae335

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

Source/Query.swift

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,17 @@ import Foundation
5757
// - ... and supplemented by an Objective-C specific artifact. To guarantee
5858
// optimal developer experience, this artifact is:
5959
//
60-
// - Named with a `z_` prefix in Swift. This ensures that it always comes
61-
// last in autocompletion drop-down menus in Swift.
60+
// - Named with a `z_objc_` prefix in Swift. This makes it clear that they
61+
// are Objective-C specific. The leading "z" ensures they are last in
62+
// autocompletion.
6263
//
6364
// - Exposed to Objective-C using the normal (unprefixed name).
6465
//
6566
// - Not documented. This ensures that it does not appear in the reference
6667
// documentation.
6768
//
6869
// This way, each platform sees a properties with the right name and the most
69-
// adequate type. The only drawback is the added clutter of the `z_`-prefixed
70+
// adequate type. The only drawback is the added clutter of the `z_objc_`-prefixed
7071
// properties in Swift.
7172
//
7273
// There is also an edge case for the `aroundRadiusAll` constant, which is not
@@ -1035,79 +1036,79 @@ public class Query : NSObject, NSCopying {
10351036
// WARNING: Should not be documented.
10361037

10371038
@objc(queryType)
1038-
public var z_queryType: String? {
1039+
public var z_objc_queryType: String? {
10391040
get { return queryType?.rawValue }
10401041
set { queryType = newValue == nil ? nil : QueryType(rawValue: newValue!) }
10411042
}
10421043

10431044
@objc(typoTolerance)
1044-
public var z_typoTolerance: String? {
1045+
public var z_objc_typoTolerance: String? {
10451046
get { return typoTolerance?.rawValue }
10461047
set { typoTolerance = newValue == nil ? nil : TypoTolerance(rawValue: newValue!) }
10471048
}
10481049

10491050
@objc(minWordSizefor1Typo)
1050-
public var z_minWordSizefor1Typo: NSNumber? {
1051+
public var z_objc_minWordSizefor1Typo: NSNumber? {
10511052
get { return Query.toNumber(self.minWordSizefor1Typo) }
10521053
set { self.minWordSizefor1Typo = newValue?.uintValue }
10531054
}
10541055

10551056
@objc(minWordSizefor2Typos)
1056-
public var z_minWordSizefor2Typos: NSNumber? {
1057+
public var z_objc_minWordSizefor2Typos: NSNumber? {
10571058
get { return Query.toNumber(self.minWordSizefor2Typos) }
10581059
set { self.minWordSizefor2Typos = newValue?.uintValue }
10591060
}
10601061

10611062
@objc(allowTyposOnNumericTokens)
1062-
public var z_allowTyposOnNumericTokens: NSNumber? {
1063+
public var z_objc_allowTyposOnNumericTokens: NSNumber? {
10631064
get { return Query.toNumber(self.allowTyposOnNumericTokens) }
10641065
set { self.allowTyposOnNumericTokens = newValue?.boolValue }
10651066
}
10661067

10671068
@objc(ignorePlurals)
1068-
public var z_ignorePlurals: NSNumber? {
1069+
public var z_objc_ignorePlurals: NSNumber? {
10691070
get { return Query.toNumber(self.ignorePlurals) }
10701071
set { self.ignorePlurals = newValue?.boolValue }
10711072
}
10721073

10731074
@objc(advancedSyntax)
1074-
public var z_advancedSyntax: NSNumber? {
1075+
public var z_objc_advancedSyntax: NSNumber? {
10751076
get { return Query.toNumber(self.advancedSyntax) }
10761077
set { self.advancedSyntax = newValue?.boolValue }
10771078
}
10781079

10791080
@objc(analytics)
1080-
public var z_analytics: NSNumber? {
1081+
public var z_objc_analytics: NSNumber? {
10811082
get { return Query.toNumber(self.analytics) }
10821083
set { self.analytics = newValue?.boolValue }
10831084
}
10841085

10851086
@objc(synonyms)
1086-
public var z_synonyms: NSNumber? {
1087+
public var z_objc_synonyms: NSNumber? {
10871088
get { return Query.toNumber(self.synonyms) }
10881089
set { self.synonyms = newValue?.boolValue }
10891090
}
10901091

10911092
@objc(replaceSynonymsInHighlight)
1092-
public var z_replaceSynonymsInHighlight: NSNumber? {
1093+
public var z_objc_replaceSynonymsInHighlight: NSNumber? {
10931094
get { return Query.toNumber(self.replaceSynonymsInHighlight) }
10941095
set { self.replaceSynonymsInHighlight = newValue?.boolValue }
10951096
}
10961097

10971098
@objc(minProximity)
1098-
public var z_minProximity: NSNumber? {
1099+
public var z_objc_minProximity: NSNumber? {
10991100
get { return Query.toNumber(self.minProximity) }
11001101
set { self.minProximity = newValue?.uintValue }
11011102
}
11021103

11031104
@objc(removeWordsIfNoResults)
1104-
public var z_removeWordsIfNoResults: String? {
1105+
public var z_objc_removeWordsIfNoResults: String? {
11051106
get { return removeWordsIfNoResults?.rawValue }
11061107
set { removeWordsIfNoResults = newValue == nil ? nil : RemoveWordsIfNoResults(rawValue: newValue!) }
11071108
}
11081109

11091110
@objc(removeStopWords)
1110-
public var z_removeStopWords: Any? {
1111+
public var z_objc_removeStopWords: Any? {
11111112
get {
11121113
if let value = removeStopWords {
11131114
switch value {
@@ -1132,13 +1133,13 @@ public class Query : NSObject, NSCopying {
11321133
}
11331134

11341135
@objc(exactOnSingleWordQuery)
1135-
public var z_exactOnSingleWordQuery: String? {
1136+
public var z_objc_exactOnSingleWordQuery: String? {
11361137
get { return exactOnSingleWordQuery?.rawValue }
11371138
set { exactOnSingleWordQuery = newValue == nil ? nil : ExactOnSingleWordQuery(rawValue: newValue!) }
11381139
}
11391140

11401141
@objc(alternativesAsExact)
1141-
public var z_alternativesAsExact: [String]? {
1142+
public var z_objc_alternativesAsExact: [String]? {
11421143
get {
11431144
if let alternativesAsExact = alternativesAsExact {
11441145
return alternativesAsExact.map({ $0.rawValue })
@@ -1162,58 +1163,58 @@ public class Query : NSObject, NSCopying {
11621163
}
11631164

11641165
@objc(page)
1165-
public var z_page: NSNumber? {
1166+
public var z_objc_page: NSNumber? {
11661167
get { return Query.toNumber(self.page) }
11671168
set { self.page = newValue?.uintValue }
11681169
}
11691170

11701171
@objc(hitsPerPage)
1171-
public var z_hitsPerPage: NSNumber? {
1172+
public var z_objc_hitsPerPage: NSNumber? {
11721173
get { return Query.toNumber(self.hitsPerPage) }
11731174
set { self.hitsPerPage = newValue?.uintValue }
11741175
}
11751176

11761177
@objc(getRankingInfo)
1177-
public var z_getRankingInfo: NSNumber? {
1178+
public var z_objc_getRankingInfo: NSNumber? {
11781179
get { return Query.toNumber(self.getRankingInfo) }
11791180
set { self.getRankingInfo = newValue?.boolValue }
11801181
}
11811182

11821183
@objc(distinct)
1183-
public var z_distinct: NSNumber? {
1184+
public var z_objc_distinct: NSNumber? {
11841185
get { return Query.toNumber(self.distinct) }
11851186
set { self.distinct = newValue?.uintValue }
11861187
}
11871188

11881189
@objc(maxValuesPerFacet)
1189-
public var z_maxValuesPerFacet: NSNumber? {
1190+
public var z_objc_maxValuesPerFacet: NSNumber? {
11901191
get { return Query.toNumber(self.maxValuesPerFacet) }
11911192
set { self.maxValuesPerFacet = newValue?.uintValue }
11921193
}
11931194

11941195
@objc(aroundLatLngViaIP)
1195-
public var z_aroundLatLngViaIP: NSNumber? {
1196+
public var z_objc_aroundLatLngViaIP: NSNumber? {
11961197
get { return Query.toNumber(self.aroundLatLngViaIP) }
11971198
set { self.aroundLatLngViaIP = newValue?.boolValue }
11981199
}
11991200

12001201
// Special value for `aroundRadius` to compute the geo distance without filtering.
1201-
@objc(aroundRadiusAll) public static let z_aroundRadiusAll: NSNumber = NSNumber(value: UInt.max)
1202+
@objc(aroundRadiusAll) public static let z_objc_aroundRadiusAll: NSNumber = NSNumber(value: UInt.max)
12021203

12031204
@objc(aroundRadius)
1204-
public var z_aroundRadius: NSNumber? {
1205+
public var z_objc_aroundRadius: NSNumber? {
12051206
get {
12061207
if let aroundRadius = aroundRadius {
12071208
switch aroundRadius {
12081209
case let .explicit(value): return NSNumber(value: value)
1209-
case .all: return Query.z_aroundRadiusAll
1210+
case .all: return Query.z_objc_aroundRadiusAll
12101211
}
12111212
}
12121213
return nil
12131214
}
12141215
set {
12151216
if let newValue = newValue {
1216-
if newValue == Query.z_aroundRadiusAll {
1217+
if newValue == Query.z_objc_aroundRadiusAll {
12171218
self.aroundRadius = .all
12181219
} else {
12191220
self.aroundRadius = .explicit(newValue.uintValue)
@@ -1225,13 +1226,13 @@ public class Query : NSObject, NSCopying {
12251226
}
12261227

12271228
@objc(aroundPrecision)
1228-
public var z_aroundPrecision: NSNumber? {
1229+
public var z_objc_aroundPrecision: NSNumber? {
12291230
get { return Query.toNumber(self.aroundPrecision) }
12301231
set { self.aroundPrecision = newValue?.uintValue }
12311232
}
12321233

12331234
@objc(minimumAroundRadius)
1234-
public var z_minimumAroundRadius: NSNumber? {
1235+
public var z_objc_minimumAroundRadius: NSNumber? {
12351236
get { return Query.toNumber(self.minimumAroundRadius) }
12361237
set { self.minimumAroundRadius = newValue?.uintValue }
12371238
}

0 commit comments

Comments
 (0)