首页 > 移动平台 > 详细

[XMPP]iOS聊天软件学习笔记[一]

时间:2015-03-26 09:02:40      阅读:261      评论:0      收藏:0      [点我收藏+]

通过前面的学习后,准备开始正式自己写一个项目

开发时间:五天(工作时间)

开发工具:xcode6

开发平台:iOS8

XMPP框架:XMPPFramework

git clone https://github.com/robbiehanson/XMPPFramework.git 

界面设计:使用StoryBoard 

github地址:https://github.com/hjandyz/XMPP

 

 第一天基本完成了“其他登陆”界面,这里只将注意点做笔记

1.枚举和block的定义并用于回调

 typedef enum {

    XMPPResultTypeLoginSuccess,

    XMPPResultTypeLoginFailure,

    XMPPResultTypeNetErr

}XMPPResultType;


typedef void (^XMPPRresultBlock)(XMPPResultType type);

 

    if (error && _resultBlock) {

        _resultBlock(XMPPResultTypeNetErr);

    }

    if (_resultBlock) {

        _resultBlock(XMPPResultTypeLoginSuccess);

    } 

2.block内要把self设置成弱指针

    __weak typeof (self) weekSelf = self;

    [delegate xmppUserLogin:^(XMPPResultType type) {

        [weekSelf handleResultTye:type];

    }];

3.切换rootViewComtroller时记得dismiss模态窗口,不然会造成内存泄漏

//隐藏模态窗口

    [self dismissViewControllerAnimated:YES completion:nil]; 

 4.建立新连接前如果已经建立过连接要断开

    //如果以前连接过要断开

    [_XMPPStream disconnect];

    //连接主机

    [self connentToHost]; 

 5.MBProgressHUD如果view为nil会显示到window上面去

[MBProgressHUD showHUDAddedTo:view animated:YES] 

6.自定义Log的方法

//自定义log

#ifdef DEBUG

#define HJLog(...) NSLog(@"%s %@",__func__,[NSString stringWithFormat:__VA_ARGS__])

#else

#define HJLog(...)

#endif 

[XMPP]iOS聊天软件学习笔记[一]

原文:http://www.cnblogs.com/hanjian/p/4367629.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!