Iphone 如何使用Xcode触发事件?

Iphone 如何使用Xcode触发事件?,iphone,xcode,events,Iphone,Xcode,Events,我想开发一个iphone应用程序,通过tcp/ip与硬件进行通信。 现在,应用程序发送到硬件是正常的。 为了便于开发,我想使用fire事件来开发接收器。 有人有什么想法吗 Joe要发起一项活动: [[NSNotificationCenter defaultCenter] postNotificationName:notificationName object:someObj]; 要收听事件,请执行以下操作: [[NSNotificationCenter defaultCenter] addOb

我想开发一个iphone应用程序,通过tcp/ip与硬件进行通信。 现在,应用程序发送到硬件是正常的。 为了便于开发,我想使用fire事件来开发接收器。 有人有什么想法吗

Joe要发起一项活动:

[[NSNotificationCenter defaultCenter] postNotificationName:notificationName object:someObj];
要收听事件,请执行以下操作:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationSelector:) name:notificationName object:notificationSender];
[[NSNotificationCenter defaultCenter] removeObserver:self name:notificationName object:notificationSender];
要停止侦听事件,请执行以下操作:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationSelector:) name:notificationName object:notificationSender];
[[NSNotificationCenter defaultCenter] removeObserver:self name:notificationName object:notificationSender];

添加2个框架
1.EventKitUI.framework
2.EventKit.framework
M
#进口
-(iAction)CreateEvent:(id)发送方{
//获取偶数存储对象
//EKEventStore*eventStore=[[EKEventStore alloc]init];
EKEventStore*eventStore=[[EKEventStore alloc]init];
/*iOS 6要求用户授予您的应用程序访问事件存储的权限*/
if([[UIDevice currentDevice].systemVersion floatValue]>=6.0)//检查设备是否为ios6
{
[eventStore requestAccessToEntityType:eEntityType提醒完成:^(已授予布尔,N错误*错误){
//在这里处理访问
}];
if([eventStore respondsToSelector:@selector(requestAccessToEntityType:完成:)]))
{
//iOS设置>隐私>日历>我的应用程序>启用|禁用
[eventStore requestAccessToEntityType:eEntityTypeEvent completion:^(已授予布尔,N错误*错误)
{
如果(授予)
{
NSLog(@“用户已授予权限!”);
}
其他的
{
NSLog(@“用户未授予权限!”);
}
}];
}
EKEventEditViewController*控制器=[[EKEventEditViewController alloc]init];
controller.eventStore=eventStore;
controller.editViewDelegate=self;
controller.wantsFullScreenLayout=是;
[self-presentModalViewController:控制器已设置动画:是];
}
其他的
{
EKEventEditViewController*控制器=[[EKEventEditViewController alloc]init];
controller.eventStore=eventStore;
controller.editViewDelegate=self;
controller.wantsFullScreenLayout=是;
[self-presentModalViewController:控制器已设置动画:是];
}
}
-(void)eventEditViewController:(EKEventEditViewController*)控制器未完成操作:(EKEventEditViewAction)操作
{
//[Bw警报:@“完成”];
UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@“完成”消息:@“事件成功保存”委托:自取消按钮:无其他按钮:无“确定”,无];
[警报显示];
[自我解散Modalviewcontrolleranimated:是];
}
@结束

n通知中心要简单得多