@@ -61,51 +61,47 @@ public protocol ObjCCompat_SubscriptionHandling {
61
61
optional func didUnsubscribe( query: PFQuery , client: Client )
62
62
}
63
63
64
+ // HACK: Compiler bug causes enums that are declared in structs that are marked as @objc to not actually be emitted by
65
+ // the compiler (lolwut?). Moving this to global scope fixes the problem, but we can't change the objc name of an enum
66
+ // either, so we pollute the swift namespace here.
67
+ // TODO: Fix this eventually.
68
+
69
+ /**
70
+ A type of an update event on a specific object from the live query server.
71
+ */
72
+ @objc
73
+ public enum PFLiveQueryEventType : Int {
74
+ /// The object has been updated, and is now included in the query.
75
+ case Entered
76
+ /// The object has been updated, and is no longer included in the query.
77
+ case Left
78
+ /// The object has been created, and is a part of the query.
79
+ case Created
80
+ /// The object has been updated, and is still a part of the query.
81
+ case Updated
82
+ /// The object has been deleted, and is no longer included in the query.
83
+ case Deleted
84
+ }
85
+
64
86
/**
65
87
This struct wraps up all of our Objective-C compatibility layer. You should never need to touch this if you're using Swift.
66
88
*/
67
89
public struct ObjCCompat {
68
90
private init ( ) { }
69
91
70
- /**
71
- A type of an update event on a specific object from the live query server.
72
- */
73
- @objc
74
- public enum PFLiveQueryEventType : Int {
75
- /// The object has been updated, and is now included in the query.
76
- case Entered
77
- /// The object has been updated, and is no longer included in the query.
78
- case Left
79
- /// The object has been created, and is a part of the query.
80
- case Created
81
- /// The object has been updated, and is still a part of the query.
82
- case Updated
83
- /// The object has been deleted, and is no longer included in the query.
84
- case Deleted
85
- }
86
-
87
92
/**
88
93
Represents an update on a specific object from the live query server.
89
94
*/
90
95
@objc ( PFLiveQueryEvent)
91
96
public class Event : NSObject {
92
97
/// Type of the event.
98
+ @objc
93
99
public let type : PFLiveQueryEventType
100
+
94
101
/// Object this event is for.
102
+ @objc
95
103
public let object : PFObject
96
104
97
- init < T> ( event: ParseLiveQuery . Event < T > ) {
98
- ( type, object) = {
99
- switch event {
100
- case . Entered( let object) : return ( . Entered, object)
101
- case . Left( let object) : return ( . Left, object)
102
- case . Created( let object) : return ( . Created, object)
103
- case . Updated( let object) : return ( . Updated, object)
104
- case . Deleted( let object) : return ( . Deleted, object)
105
- }
106
- } ( )
107
- }
108
-
109
105
init ( type: PFLiveQueryEventType , object: PFObject ) {
110
106
self . type = type
111
107
self . object = object
@@ -329,6 +325,25 @@ extension Client {
329
325
}
330
326
}
331
327
328
+ // HACK: Another compiler bug - if you have a required initializer with a generic type, the compiler simply refuses to
329
+ // emit the entire class altogether. Moving this to an extension for now solves the issue.
330
+
331
+ extension ObjCCompat . Event {
332
+ convenience init < T> ( event: ParseLiveQuery . Event < T > ) {
333
+ let results : ( type: PFLiveQueryEventType , object: PFObject ) = {
334
+ switch event {
335
+ case . Entered( let object) : return ( . Entered, object)
336
+ case . Left( let object) : return ( . Left, object)
337
+ case . Created( let object) : return ( . Created, object)
338
+ case . Updated( let object) : return ( . Updated, object)
339
+ case . Deleted( let object) : return ( . Deleted, object)
340
+ }
341
+ } ( )
342
+
343
+ self . init ( type: results. type, object: results. object)
344
+ }
345
+ }
346
+
332
347
extension PFQuery {
333
348
/**
334
349
Register this PFQuery for updates with Live Queries.
0 commit comments