小型库,用于在 iOS 应用和扩展之间传递消息。RemoteBus 通过模拟应用程序和扩展之间的总线,提供了一种同步数据或简单传递事件的方法。
// Create bus for this app group and name
remoteBus = [[RBRemoteBus alloc] initWithName:@"OneBus" appGroupIdentifier:@"group.com.arturogutierrez.remotebus"];
// Subscribe for remote events
[remoteBus subscribeForIdentifier:@"SomeEventIdentifier" subscriber:^(RBMessage *message) {
NSString *text = (NSString *) message.body;
[self.label setText:text];
}];
// Pass an event
RBMessage *message = [[RBMessage alloc] initWithIdentifier:@"AnotherEventIdentifier" body:@"Hey there!"];
[remoteBus sendMessage:message];
它将很快通过 CocoaPods 提供使用。
Copyright 2015 Arturo Gutiérrez Díaz-Guerra
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://apache.ac.cn/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.