理解iOS7的Multipeer Connectivity框架

例子可跑

http://www.oschina.net/translate/intro-multipeer-connectivity-framework-ios-programming?lang=chs&page=1#

git
https://github.com/kakegawa-atsushi/MultipeerConnectivitySample


//
// FirstViewController.m
// MCDemo
//
//

#import "FirstViewController.h"
#import "AppDelegate.h"

@interface FirstViewController ()

@property (nonatomic, strong) AppDelegate *appDelegate;

-(void)sendMyMessage;
-(void)didReceiveDataWithNotification:(NSNotification *)notification;

@end

@implementation FirstViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

_appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

_txtMessage.delegate = self;

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveDataWithNotification:)
name:@"MCDidReceiveDataNotification"
object:nil];
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}


#pragma mark - UITextField Delegate method implementation

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[self sendMyMessage];
return YES;
}


#pragma mark - IBAction method implementation

- (IBAction)sendMessage:(id)sender {
[self sendMyMessage];
}

- (IBAction)cancelMessage:(id)sender {
[_txtMessage resignFirstResponder];
}


#pragma mark - Private method implementation

-(void)sendMyMessage{
NSData *dataToSend = [_txtMessage.text dataUsingEncoding:NSUTF8StringEncoding];
NSArray *allPeers = _appDelegate.mcManager.session.connectedPeers;
NSError *error;

[_appDelegate.mcManager.session sendData:dataToSend
toPeers:allPeers
withMode:MCSessionSendDataReliable
error:&error];

if (error) {
NSLog(@"%@", [error localizedDescription]);
}

[_tvChat setText:[_tvChat.text stringByAppendingString:[NSString stringWithFormat:@"I wrote:\n%@\n\n", _txtMessage.text]]];
[_txtMessage setText:@""];
[_txtMessage resignFirstResponder];
}


-(void)didReceiveDataWithNotification:(NSNotification *)notification{
MCPeerID *peerID = [[notification userInfo] objectForKey:@"peerID"];
NSString *peerDisplayName = peerID.displayName;

NSData *receivedData = [[notification userInfo] objectForKey:@"data"];
NSString *receivedText = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];

[_tvChat performSelectorOnMainThread:@selector(setText:) withObject:[_tvChat.text stringByAppendingString:[NSString stringWithFormat:@"%@ wrote:\n%@\n\n", peerDisplayName, receivedText]] waitUntilDone:NO];
}

@end

VxWorks环境搭建与学习:vxworks6.8和workbench3.2 VxWorks操作系统是美国WindRiver公司于1983年设计开发的一种嵌入式实时操作系统(RTOS),是嵌入式开发环境的关键组成部分。良好的持续能力、高性能的内核以及友好的用户开发环境,在嵌入式实时操作系统领域占据一席之地。它以其良好的可靠性和卓越的实时性被广泛地应用在通信、军事、航空、航天等高精尖技术及实时性要求极高的领域中,如卫星通讯、军事演习、弹道制导、飞机导航等。 阅读详情

相关推荐

VL53L0X加盖玻片后精度暴跌?手把手教你完成串扰校准(CrossTalk Calibration)

本文详细解析了VL53L0X激光测距传感器加盖玻片后精度下降的原因,并提供了串扰校准(CrossTalk Calibration)的完整解决方案。通过分步指导和实用代码示例,帮助工程师恢复毫米级测距精度,适用于智能门锁、扫地机器人等应用场景。

weixin_33708432的博客 539

鲜为人知的Multipeer Connectivity(部分转载)

相信大家对AirDrop都比较熟悉,AirDrop不要求两台机器在同一个网络内,不管是在mac笔记本还是iphone,只需要打开AirDrop就可以将文件分享给附近的人。在iOS7中,引入了一个全新的框架——Multipeer Connectivity(多点连接),利用这一框架,即使在没有连接到WiFi或移动网络的情况下,距离较近的Apple设备之间可基于蓝牙和WiFi技术进行近场通信。与AirD

wu__di的博客 1787

tuts4you-lena151-Crackme-tutorial06

一、前言      本次研究的是lena151-Crackme-tutorial06,也是一个应用程序,但因为平台迭代的关系,程序不能正常运行,只能完成部分破解。 (一)·本次我们要破解的目标是个应用程序,如下图 (二)、使用工具:x32dbg 二、过程 这个程序的破解的方法很多,首先最简单的一种不外乎就是搜索字符串,我就按照这个思路来完成。 (一)查找字符串<Unregis...

h123120的专栏 518

iOS7新特征汇总[03]新特征介绍3

本文转载自:破船之家 本文地址:iOS7新特征汇总[03]新特征介绍3 小引 上一篇文章(iOS7新特征汇总[02]新特征介绍2)中,笔者介绍了在iOS7中关于游戏、地图和AirDrop相关内容。本文将继续介绍iOS7中的新特征:程序间的音频(inter-App Audio)、点对点的连接、新增的Framework。 程序间的音频(inter-App Audio)

Acorld 2879

【Unity】NGUI下载与导入

Unity3D插件NGUI的下载和导入。

Get your hands dirty 3万+

华为OD机试真题2025双机位A卷 C++ 实现【采购订单】

在一个采购系统中,采购申请(PR)需要经过审批后才能生成采购订单(PO)。每个PR包含商品的单价(假设相同商品的单价一定是一样的)及数量信息。系统要求对商品进行分类处理:单价高于100元的商品需要单独处理,单价低于或等于100元的相同商品可以合并到同一采购订单PO中。针对单价低于100的小额订单,如果量大可以打折购买。

MISAYAONE的博客 674

The Wisdom of Quinn本地网络隐私FAQ:17个权限弹窗与多播Entitlement完整问答指南

**The Wisdom of Quinn** 是 Apple DTS 工程师 "The Eskimo"(Quinn)在 Apple 开发者论坛上的精华文章归档库(Share and Enjoy®),其中 **本地网络隐私(Local Network Privacy)** 主题收录了官方 FAQ 的 17 个问答,围绕 **权限弹窗(Privacy Alert)** 与 **多播 Entitlem

gitblog_00105的博客 435

基于OpenClaw的自动化文件管理与文档分类系统设计与实现

本文介绍了一种基于OpenClaw的自动化文件管理与文档分类系统。系统采用三层架构设计,包含数据层、逻辑层和应用层,核心组件涵盖文件扫描、处理、分类、移动等功能。技术选型上使用Python/FastAPI作为后端,结合PostgreSQL/Elasticsearch/MinIO存储方案,并整合scikit-learn/PyTorch等AI技术实现智能分类。系统实现了文件递归扫描、增量扫描、元数据提取等功能,通过文件哈希和修改时间检测变化。该方案能有效提升文件管理效率,实现文档的自动化分类与智能管理。

一键难忘的博客 753

MultipeerConnectivity框架,近场通信的基本使用

  Multipeer connectivity是一个使附近设备通过Wi-Fi网络、P2P Wi-Fi以及蓝牙个人局域网进行通信的框架。互相链接的节点可以安全地传递信息、流或是其他文件资源,而不用通过网络服务。此框架是在iOS7以后推出,旨在替代GameKit下的GKPeerPickerController通信。通过此框架我们可以直接连接同一网络下的设备,让其直接进行类似微信,qq那样的即时通讯效...

weixin_30640769的博客 327

计算机组成原理(第三版)唐朔飞-第三章系统总线-课后习题

计算机组成原理(第三版)唐朔飞-第三章系统总线-课后习题

weixin_45735391的博客 6万+

【Windows Server 2019】DNS服务器的配置与管理——DNS正向解析

博文介绍了如何使用正向解析区,包括创建和添加并验证,以及术语 主机记录,别名,邮件交换记录的解释。

VMware, Windows, Linux, Cisco, Container, Kubernetes, Kali 1万+

facebook的socketrocket总结

最近看了开源的网易的demo [url]https://netease.im/[/url] 关键类 NTESSessionViewController.m 发送函数 [code="java"] #pragma mark - 消息发送时间截获 - (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError ...

走在左边 2586

TensorRT - 使用自定义层扩展 TensorRT

TensorRT 支持通过自定义插件扩展功能。开发者可以基于 IPluginV3 接口实现插件类,并通过 IPluginCreatorV3One 创建器类注册到 TensorRT 插件注册表。插件实现需要包含核心、构建和运行时三种能力,并通过静态或动态方式注册。最后可使用 addPluginV3() 将插件实例添加到 TensorRT 网络中。这种方法允许在标准层不满足需求时,使用自定义层扩展模型功能。

1148

ios仿微信的demo

10月19日闲的蛋疼,做了个 仿微信的聊天工具 git地址:[url]https://github.com/killinux/mysocket/tree/master/websocket/project/Test[/url] ui参考的网上例子http://ios.9tech.cn/news/2013/1111/38520.html 服务端用 tomcat7的websocket 客户...

走在左边 720

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

m3u8在windows上预览

[code="java"] Provider tests body { padding: 50px; font: 13px/20px Arial; background: #EEE; } form { margin-top: 20px; } #player { -webkit-box-shado...

走在左边 718

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

ios上使用gcc

安装network-cmds apptitude iphone-gcc ldid vim 终于搞定了,原来是缺少头文件。 由于头文件为苹果公司所有,随便把它加入到iPhone-gcc的包中来都是非法的,所以开发iPhone-gcc的人并没有把它加进来,但是最后还是告诉了一个如何获得该头文件的方法,详情请见: http://code.google.com/p/iphone-gc...

走在左边 696

ios的opencv的helloworld

xcode6, 学习的源码在 http://opencv.org/opencv-for-ios-samples.html https://github.com/Itseez/opencv_for_ios_book_samples 设置参考:http://www.devtang.com/blog/2012/10/27/use-opencv-in-ios/ 在xcode6中的 Buil...

走在左边 540

生成ipa 这个是自己总结的,ios5.1.1越狱系统,xcode4.3.3可用

最有用的一段 [code="java"] export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate if [ "${PLATFORM_NAME}" == "iphoneos" ] || [...

走在左边 360

linux下编译objectc

编译静态库给ios使用 http://www.tuicool.com/articles/UZr6z2 1. $ yum -y install gcc-objc 2. 从http://wwwmain.gnustep.org下载GNUstep Startup和GNUstep Base,并从源码进行安装。 3.. $ export PATH=$PATH:/usr/GNUstep/Syste...

走在左边 290

cocoahttpserver

https://github.com/robin/cocoa-web-resource 这个挺好玩

走在左边 243

ios客户端websocket的helloworld

ios8,xcode6 [url]https://github.com/square/SocketRocket[/url] [url]https://github.com/killinux/SocketRocket[/url] 中的一个文件夹SocketRocket,3包含三个文件 SRWebSocket.h SRWebSocket.m SocketRocket-Prefix.pc...

走在左边 234

ios指南针

参考http://blog.sina.com.cn/s/blog_4a37054201013nhr.html 可运行的代码如下 1.拖拽ImageView ,关联变量到.h中 2.代码如下 [code="java"] // // ViewController.h // SouthDemo // // Created by xiao7 on 14/10/25. // Co...

走在左边 199

自制微信的ui

参考http://ios.9tech.cn/news/2013/1111/38520.html 修改 配置绑定 [img]http://dl2.iteye.com/upload/attachment/0102/1755/5d41ad8b-4761-331f-aa59-f5b142a17795.png[/img] [code="java"] #import @interface...

走在左边 198
上一篇: webgl的贝塞尔曲线
下一篇: 打包ipa
linux内核控
博客等级 码龄19年 41粉丝 638原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值