Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit dd34fa1

Browse files
Add objective-c example app, make swift example use AppKit for proper linking.
1 parent 6febfb5 commit dd34fa1

File tree

16 files changed

+1013
-95
lines changed

16 files changed

+1013
-95
lines changed

Examples/LiveQueryDemo-ObjC.xcodeproj/project.pbxproj

Lines changed: 412 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0730"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "F509D5311CA9E597007B15B0"
18+
BuildableName = "LiveQueryDemo-ObjC.app"
19+
BlueprintName = "LiveQueryDemo-ObjC"
20+
ReferencedContainer = "container:LiveQueryDemo-ObjC.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
<MacroExpansion>
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "F509D5311CA9E597007B15B0"
36+
BuildableName = "LiveQueryDemo-ObjC.app"
37+
BlueprintName = "LiveQueryDemo-ObjC"
38+
ReferencedContainer = "container:LiveQueryDemo-ObjC.xcodeproj">
39+
</BuildableReference>
40+
</MacroExpansion>
41+
<AdditionalOptions>
42+
</AdditionalOptions>
43+
</TestAction>
44+
<LaunchAction
45+
buildConfiguration = "Debug"
46+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
47+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
48+
launchStyle = "0"
49+
useCustomWorkingDirectory = "NO"
50+
ignoresPersistentStateOnLaunch = "NO"
51+
debugDocumentVersioning = "YES"
52+
debugServiceExtension = "internal"
53+
allowLocationSimulation = "YES">
54+
<BuildableProductRunnable
55+
runnableDebuggingMode = "0">
56+
<BuildableReference
57+
BuildableIdentifier = "primary"
58+
BlueprintIdentifier = "F509D5311CA9E597007B15B0"
59+
BuildableName = "LiveQueryDemo-ObjC.app"
60+
BlueprintName = "LiveQueryDemo-ObjC"
61+
ReferencedContainer = "container:LiveQueryDemo-ObjC.xcodeproj">
62+
</BuildableReference>
63+
</BuildableProductRunnable>
64+
<AdditionalOptions>
65+
</AdditionalOptions>
66+
</LaunchAction>
67+
<ProfileAction
68+
buildConfiguration = "Release"
69+
shouldUseLaunchSchemeArgsEnv = "YES"
70+
savedToolIdentifier = ""
71+
useCustomWorkingDirectory = "NO"
72+
debugDocumentVersioning = "YES">
73+
<BuildableProductRunnable
74+
runnableDebuggingMode = "0">
75+
<BuildableReference
76+
BuildableIdentifier = "primary"
77+
BlueprintIdentifier = "F509D5311CA9E597007B15B0"
78+
BuildableName = "LiveQueryDemo-ObjC.app"
79+
BlueprintName = "LiveQueryDemo-ObjC"
80+
ReferencedContainer = "container:LiveQueryDemo-ObjC.xcodeproj">
81+
</BuildableReference>
82+
</BuildableProductRunnable>
83+
</ProfileAction>
84+
<AnalyzeAction
85+
buildConfiguration = "Debug">
86+
</AnalyzeAction>
87+
<ArchiveAction
88+
buildConfiguration = "Release"
89+
revealArchiveInOrganizer = "YES">
90+
</ArchiveAction>
91+
</Scheme>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Copyright (c) 2016-present, Parse, LLC.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
@import Foundation;
11+
@import Parse;
12+
@import ParseLiveQuery;
13+
14+
#import "Message.h"
15+
16+
NS_ASSUME_NONNULL_BEGIN
17+
18+
@class ChatRoomManager;
19+
20+
@protocol ChatRoomManagerDatasource <NSObject>
21+
22+
- (PFQuery *)queryForChatRoomManager:(ChatRoomManager *)manager;
23+
- (PFLiveQueryClient *)liveQueryClientForChatRoomManager:(ChatRoomManager *)manager;
24+
25+
@end
26+
27+
@protocol ChatRoomManagerDelegate <NSObject>
28+
29+
- (void)chatRoomManager:(ChatRoomManager *)manager didReceiveMessage:(Message *)message;
30+
31+
@end
32+
33+
@interface ChatRoomManager : NSObject
34+
35+
@property (nonatomic, readonly, getter=isConnected) BOOL connected;
36+
@property (nonatomic, readonly, weak) id<ChatRoomManagerDatasource> datasource;
37+
@property (nonatomic, readonly, weak) id<ChatRoomManagerDelegate> delegate;
38+
39+
- (instancetype)initWithDatasource:(id<ChatRoomManagerDatasource>)datasource delegate:(id<ChatRoomManagerDelegate>)delegate;
40+
41+
- (void)connect;
42+
- (void)disconnect;
43+
44+
@end
45+
46+
NS_ASSUME_NONNULL_END
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// ChatRoomManager.m
3+
// LiveQueryDemo-ObjC
4+
//
5+
// Created by Richard Ross on 3/28/16.
6+
// Copyright © 2016 parse. All rights reserved.
7+
//
8+
9+
#import "ChatRoomManager.h"
10+
11+
@interface ChatRoomManager()
12+
13+
@property (nonatomic, strong) PFLiveQueryClient *client;
14+
@property (nonatomic, strong) PFQuery *query;
15+
@property (nonatomic, strong) PFLiveQuerySubscription *subscription;
16+
17+
@end
18+
19+
@implementation ChatRoomManager
20+
21+
- (instancetype)initWithDatasource:(id<ChatRoomManagerDatasource>)datasource delegate:(id<ChatRoomManagerDelegate>)delegate{
22+
self = [super init];
23+
if (!self) return self;
24+
25+
_datasource = datasource;
26+
_delegate = delegate;
27+
28+
return self;
29+
}
30+
31+
- (BOOL)isConnected {
32+
return self.subscription != nil;
33+
}
34+
35+
- (void)connect {
36+
self.client = [self.datasource liveQueryClientForChatRoomManager:self];
37+
self.query = [self.datasource queryForChatRoomManager:self];
38+
39+
__weak typeof(self) weakSelf = self;
40+
self.subscription = [[self.client subscribeToQuery:self.query] addCreateHandler:^(PFQuery *query, PFObject *message) {
41+
[weakSelf.delegate chatRoomManager:weakSelf didReceiveMessage:(Message *)message];
42+
}];
43+
}
44+
45+
- (void)disconnect {
46+
self.client = nil;
47+
self.query = nil;
48+
self.subscription = nil;
49+
}
50+
51+
@end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIconFile</key>
10+
<string></string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleSignature</key>
22+
<string>????</string>
23+
<key>CFBundleVersion</key>
24+
<string>1</string>
25+
<key>LSMinimumSystemVersion</key>
26+
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
27+
<key>NSHumanReadableCopyright</key>
28+
<string>Copyright © 2016 Parse. All rights reserved.</string>
29+
<key>NSPrincipalClass</key>
30+
<string>NSApplication</string>
31+
</dict>
32+
</plist>

Examples/LiveQueryDemo-ObjC/Message.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright (c) 2016-present, Parse, LLC.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import <Parse/Parse.h>
11+
12+
NS_ASSUME_NONNULL_BEGIN
13+
14+
@interface Message : PFObject<PFSubclassing>
15+
16+
@property (nonatomic, strong, nullable) PFUser *author;
17+
@property (nonatomic, strong, nullable) NSString *authorName;
18+
@property (nonatomic, strong, nullable) NSString *message;
19+
@property (nonatomic, strong, nullable) PFObject *room;
20+
@property (nonatomic, strong, nullable) NSString *roomName;
21+
22+
@end
23+
24+
NS_ASSUME_NONNULL_END

Examples/LiveQueryDemo-ObjC/Message.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) 2016-present, Parse, LLC.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import "Message.h"
11+
12+
@implementation Message
13+
14+
@dynamic author, authorName, message, room, roomName;
15+
16+
+ (NSString *)parseClassName {
17+
return @"Message";
18+
}
19+
20+
@end

Examples/LiveQueryDemo-ObjC/Room.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) 2016-present, Parse, LLC.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import <Parse/Parse.h>
11+
12+
NS_ASSUME_NONNULL_BEGIN
13+
14+
@interface Room : PFObject<PFSubclassing>
15+
16+
@property (nonatomic, strong, nullable) NSString *name;
17+
18+
@end
19+
20+
NS_ASSUME_NONNULL_END

Examples/LiveQueryDemo-ObjC/Room.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) 2016-present, Parse, LLC.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import "Room.h"
11+
12+
@implementation Room
13+
14+
@dynamic name;
15+
16+
+ (NSString *)parseClassName {
17+
return @"Room";
18+
}
19+
20+
@end

0 commit comments

Comments
 (0)