League of Legends 的 iOS 和 OS X 聊天服务库。
将以下内容添加到您的 Podfile
中,然后运行 pod install
pod 'Folklore'
不要忘记 #import <Folklore/Folklore.h>
。
- (void)didTapConnectButton:(id)sender {
_folklore = [[Folklore alloc] initWithServerRegion:LoLServerRegionNorthAmerica];
[_folklore setDelegate:self];
[_folklore connectWithUsername:@"jdoe"
password:@"secret123"];
}
#pragma mark - FolkloreDelegate Protocol
- (void)folkloreDidConnect:(Folklore *)folklore {
NSLog(@"Connection successful");
}
- (void)folkloreConnection:(Folklore *)folklore didFailWithError:(NSError *)error {
NSLog(@"Connection failed with error: %@", error);
}
#pragma mark - FolkloreDelegate Protocol
- (void)folklore:(Folklore *)folklore didPopulateBuddyList:(NSArray *)buddyList {
for (FolkloreBuddy *buddy in buddyList) {
NSLog(@"%@ is %@", buddy.name, (buddy.isOnline ? @"online" : @"offline"));
}
}
// `_buddies` is a NSArray of FolkloreBuddy objects, obtained during a buddy list update.
[_folklore sendMessage:@"Welcome to Summoner's Rift!" toBuddy:_buddyList[index]];
#pragma mark - FolkloreDelegate Protocol
- (void)folklore:(Folklore *)folklore didReceiveMessage:(NSString *)message fromBuddy:(FolkloreBuddy *)buddy {
NSLog(@"[%@] %@", buddy.name, message);
}
传说遵从 MIT 许可协议。有关更多信息,请参阅 LICENSE 文件。
《英雄联盟》的内容和材料是 Riot Games 或其许可人的商标和版权。版权所有。