[XMPP]iOS聊天软件学习笔记[一]
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
通过前面的学习后,准备开始正式自己写一个项目
开发时间:五天(工作时间)
开发工具: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
最新文章
- java 中Session 持久化问题
- php导入excel
- My Package
- 顺序执行到来的消息 actor
- Java-ArrayList和Vector的区别
- eclupse启动报 Failed to load JavaHL Library.错
- eclips中增加对jar包的引用
- 解决 MVC 用户上线下线状态问题
- UITableViewCell和UITableViewHeaderFooterView的重用
- javaFile循环列出指定目录下的所有文件(源代码)
- 一、Django的基本用法
- 使用reflector对.NET反编译
- win10 python27pyhton36共存
- spark-sql(spark sql cli)客户端集成hive
- SpringMvc 文件下载 详解
- 【待补】splay 模板
- string 常量池 栈 堆
- bzoj 4034: [HAOI2015]树上操作 (树剖+线段树 子树操作)
- opencv在同一窗口打印多张图片
- iptables简单规则记录
热门文章
- js实现选项卡切换的三种方式
- win7 下的open live writer代码插件
- Codeforces Round #276 (Div. 2) 解题报告
- layout_weight
- 2015北大夏令营day1 B:An Idea of Mr. A
- VS2010中使用QtOpenGL出现 unresolved external symbol __imp__glClear@4 referenced in function之类的错误
- Roman numerals
- Binary Search Tree BST Template
- UVA1218--树形DP
- 【BBST 之伸展树 (Splay Tree)】