我希望我发布这个问题不会违反 NDA。
我正在使用新的多点连接使用蓝牙将一些文件发送到附近的设备。我已经设法发送邀请,但我似乎不知道如何显示 UIAlertView 用户可以接受或拒绝邀请的地方。现在,当用户发送时,文件会自动保存,并且没有接受/拒绝警报。
代码是:
- (void) advertiser:(MCNearbyServiceAdvertiser *)advertiser
didReceiveInvitationFromPeer:(MCPeerID *)peerID
withContext:(NSData *)context
invitationHandler:(void(^)(BOOL accept,
MCSession *session))invitationHandler{
... save the data context
但有警报:
- (void) advertiser:(MCNearbyServiceAdvertiser *)advertiser
didReceiveInvitationFromPeer:(MCPeerID *)peerID
withContext:(NSData *)context
invitationHandler:(void(^)(BOOL accept,
MCSession *session))invitationHandler{
DevicePeer = [MCPeerID alloc];
DevicePeer = peerID;
ArrayInvitationHandler = [NSArray arrayWithObject:[invitationHandler copy]];
// ask the user
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@""
message:@""
delegate:self
cancelButtonTitle:@"NO"
otherButtonTitles:@"YES", nil];
[alertView show];
alertView.tag = 2;
}
和警报视图方法:
- (void) alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex
{
// retrieve the invitationHandler
// get user decision
BOOL accept = (buttonIndex != alertView.cancelButtonIndex) ? YES : NO;
// respond
MCSession *session = [ArrayInvitationHandler objectAtIndex:0];
void (^invitationHandler)(BOOL, MCSession *) = [ArrayInvitationHandler objectAtIndex:0];
invitationHandler(accept, session);
}
当用户按下是时,应用程序崩溃并且我收到错误:
[__NSMallocBlock__ nearbyConnectionDataForPeer:withCompletionHandler:]: unrecognized selector sent to instance 0x14d4e3b0'
我查看了IOS开发人员库,除了没有这样的方法
- (void)nearbyConnectionDataForPeer:(id)arg1 withCompletionHandler:(id)arg2{
}
这不起作用。IOS 开发者论坛上没有信息。有任何想法吗?