﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-一点一滴，编程人生</title><link>http://www.blogjava.net/writegull/</link><description /><language>zh-cn</language><lastBuildDate>Sun, 03 May 2026 15:07:14 GMT</lastBuildDate><pubDate>Sun, 03 May 2026 15:07:14 GMT</pubDate><ttl>60</ttl><item><title>使用atomikos连接mysql报错 Raised -5: invalid arguments were given for the XA operation 或 XAER_INVAL: Invalid arguments (or unsupported command)</title><link>http://www.blogjava.net/writegull/archive/2017/06/28/432634.html</link><dc:creator>writegull</dc:creator><author>writegull</author><pubDate>Wed, 28 Jun 2017 11:32:00 GMT</pubDate><guid>http://www.blogjava.net/writegull/archive/2017/06/28/432634.html</guid><wfw:comment>http://www.blogjava.net/writegull/comments/432634.html</wfw:comment><comments>http://www.blogjava.net/writegull/archive/2017/06/28/432634.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/writegull/comments/commentRss/432634.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/writegull/services/trackbacks/432634.html</trackback:ping><description><![CDATA[今天为了这个问题了忙乎了一整天，特此记录下，希望对有遇到同样问题的同学有帮助。事情的经过是这样的，原先使用atomikos一直把数据源用jndi配置到tomcat的context.xml下，一直这么用没有出现问题，配置如下<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">Resource&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="jdbc/cms"</span><span style="color: #FF0000; ">&nbsp;auth</span><span style="color: #0000FF; ">="Container"</span><span style="color: #FF0000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type</span><span style="color: #0000FF; ">="com.atomikos.jdbc.AtomikosDataSourceBean"</span><span style="color: #FF0000; ">&nbsp;factory</span><span style="color: #0000FF; ">="com.atomikos.tomcat.EnhancedTomcatAtomikosBeanFactory"</span><span style="color: #FF0000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;uniqueResourceName</span><span style="color: #0000FF; ">="jdbc/cms"</span><span style="color: #FF0000; ">&nbsp;xaDataSourceClassName</span><span style="color: #0000FF; ">="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"</span><span style="color: #FF0000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xaProperties.URL</span><span style="color: #0000FF; ">="xxxx"</span><span style="color: #FF0000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xaProperties.user</span><span style="color: #0000FF; ">="xxxx"</span><span style="color: #FF0000; ">&nbsp;xaProperties.password</span><span style="color: #0000FF; ">="xxxx"</span><span style="color: #FF0000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xaProperties.pinGlobalTxToPhysicalConnection</span><span style="color: #0000FF; ">="true"</span><span style="color: #FF0000; ">&nbsp;maxLifetime</span><span style="color: #0000FF; ">="60"</span><span style="color: #FF0000; ">&nbsp;poolSize</span><span style="color: #0000FF; ">="4"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span></div><br />最近项目要迁移到maven下，所以把context.xml的数据源配置挪到了spring.xml下，配置如下<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">bean&nbsp;</span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">="myDataSource"</span><span style="color: #FF0000; ">&nbsp;class</span><span style="color: #0000FF; ">="com.atomikos.jdbc.AtomikosDataSourceBean"</span><span style="color: #FF0000; ">&nbsp;init-method</span><span style="color: #0000FF; ">="init"</span><span style="color: #FF0000; ">&nbsp;destroy-method</span><span style="color: #0000FF; ">="close"</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="uniqueResourceName"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="masterDB"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="xaDataSourceClassName"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;</span><span style="color: #008000; ">&lt;!--</span><span style="color: #008000; ">&nbsp;SQLErrorCodes&nbsp;loaded:&nbsp;[DB2,&nbsp;Derby,&nbsp;H2,&nbsp;HSQL,&nbsp;Informix,&nbsp;MS-SQL,&nbsp;MySQL,&nbsp;Oracle,&nbsp;PostgreSQL,&nbsp;Sybase,&nbsp;Hana]&nbsp;&nbsp;</span><span style="color: #008000; ">--&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="poolSize"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="0"</span><span style="color: #FF0000; ">&nbsp;</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="minPoolSize"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="0"</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="maxPoolSize"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="9"</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="borrowConnectionTimeout"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="60"</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="reapTimeout"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="20"</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="maxIdleTime"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="60"</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="maintenanceInterval"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="60"</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="loginTimeout"</span><span style="color: #FF0000; ">&nbsp;value</span><span style="color: #0000FF; ">="60"</span><span style="color: #0000FF; ">/&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="xaProperties"</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">props</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">prop&nbsp;</span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="url"</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">xxxx</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">prop</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">prop&nbsp;</span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="user"</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">xxxx</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">prop</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">prop&nbsp;</span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="password"</span><span style="color: #0000FF; ">&gt;xxxx</span><span style="color: #000000; "></span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">prop</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">props</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">property</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">&gt;</span></div>因为上面这个配置我是照搬网上的，所以觉得没有问题，可是项目启动后，用此数据源提交事务时确报以下错误：<br /><br /><div><div>Raised -5: invalid arguments were given for the XA operation 或 XAER_INVAL: Invalid arguments (or unsupported command)<br /><br />一开始我以为maven配置的mysql-connector-java驱动版本不对，或是atomikos版本不对，可是不管如何换版本都不行，就快要疯了的时候，我看到了原先jndi方式中有这么一行代码 <div><span style="color: red; background-color: yellow;">xaProperties.pinGlobalTxToPhysicalConnection</span><span style="color: red; background-color: yellow;">="true"<br /><span style="background-color: #000000;"><span style="background-color: #ffffff;"></span></span></span>就因为缺少上面这句话导致了问题,上网查资料，据说是mysql xa bug，有兴趣的可以看如下连接，最后配置如下：<div><a href="https://www.atomikos.com/Documentation/KnownProblems#MySQL_XA_bug">https://www.atomikos.com/Documentation/KnownProblems#MySQL_XA_bug</a></div><span style="color: red; background-color: yellow;"><span></span></span><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">property&nbsp;</span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="xaProperties"</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">props</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">prop&nbsp;</span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="pinGlobalTxToPhysicalConnection"</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">true</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">prop</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;</span><span style="color: #008000; ">&lt;!--</span><span style="color: #008000; ">&nbsp;mysql必须配置此参数，要不然无法提交事务&nbsp;</span><span style="color: #008000; ">--&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">prop&nbsp;</span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="url"</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">xxxx</span><span style="color: #FF0000; "></span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">prop</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">prop&nbsp;</span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="user"</span><span style="color: #0000FF; ">&gt;xxx</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">prop</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">prop&nbsp;</span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="password"</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">xxxx</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">prop</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">props</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; "><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">property</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">&nbsp; <br /></span></div><span style="color: red; background-color: yellow;"><span><br /></span></span></div></div></div><br /><br /><img src ="http://www.blogjava.net/writegull/aggbug/432634.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/writegull/" target="_blank">writegull</a> 2017-06-28 19:32 <a href="http://www.blogjava.net/writegull/archive/2017/06/28/432634.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>redis未授权访问缺陷导致系统被黑</title><link>http://www.blogjava.net/writegull/archive/2015/12/15/428651.html</link><dc:creator>writegull</dc:creator><author>writegull</author><pubDate>Mon, 14 Dec 2015 17:13:00 GMT</pubDate><guid>http://www.blogjava.net/writegull/archive/2015/12/15/428651.html</guid><wfw:comment>http://www.blogjava.net/writegull/comments/428651.html</wfw:comment><comments>http://www.blogjava.net/writegull/archive/2015/12/15/428651.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.blogjava.net/writegull/comments/commentRss/428651.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/writegull/services/trackbacks/428651.html</trackback:ping><description><![CDATA[事情描述：<br />本人在阿里云上创建了一个linux服务器，跑了一个自己的测试web项目。搭建了redis。想方便测试用，就没有对redis进行任何安全防护并暴露在了公网上。期间阿里云发现了此问题，还发短信提醒我，由于最近在公司一直加班也没有时间理会，没想到就在今天真的被黑了，事后心想多亏是个测试服务器，如果是正式环境，也真危险，这个黑客也没有停下脚步，通过redis强大的能力在/root/.ssh目录下面上传了公钥，彻底攻破了服务器，免密码登录服务器，一般黑客到这步也就看看有没有兴趣的数据，这个黑客一看这就是个没有价值的测试服务器，所以心一横，在我这上面装了个DDOS攻击软件，把我的机器当起肉鸡。<br /><br />1.这就是黑完后留下的公钥/私钥，删除authorized_keys，id_rsa， id_rsa.pub这三个文件吧，除非还想让他继续黑下去。。。。<br /><img src="http://www.blogjava.net/images/blogjava_net/writegull/redis1.png" alt="" border="0" /><br /><br />2.通过redis的key *命令可以看到有个叫crackit的key。这就是黑客在入侵后留下来的，原先set的值是公钥，入侵成功之后就改成这个了，把这个key也删除掉吧。<br /><img src="http://www.blogjava.net/images/blogjava_net/writegull/redis2.png" alt="" border="0" height="216" width="675" /><br /><br />3.修改redis默认端口吧，不让黑客利用6379端口。在redis安装目录中，修改redis.config文件。修改完了别忘了重启redis服务,<div><p>#&nbsp;redis-server&nbsp;/etc/redis/redis.conf 开启</p>   <p>#&nbsp;redis-cli&nbsp;shutdown 关闭</p></div><img src="http://www.blogjava.net/images/blogjava_net/writegull/redis3.png" alt="" border="0" height="64" width="543" /><br /><br />4.重启后查看redis是否运行<br /><div>ps -x | grep redis<br /></div>5.通过指定端口访问redis。<br />redis-cli -p 6666<br /><br />6.给redis设置密码或者干脆设置成只能内网访问<br /><br />7.通过top命令发现了几个可疑的程序<br /><img alt="" src="http://www.blogjava.net/images/blogjava_net/writegull/redis4.png" height="584" width="1139" /><br /><br /><br />8.minerd这个程序是个用来挖掘莱特币的，这个黑客看来干了不少坏事啊。。我们用命令 ps -ef|grep minerd 查找一下这个进程，杀掉这个进程kill -9 18267，并且去/tmp目录删除minerd目录<br /><img alt="" src="http://www.blogjava.net/images/blogjava_net/writegull/redis5.png" height="200" width="995" /><br /><br />9.黑客在tmp目录留下了一个叫1.sh的脚本，是用来下载挖掘莱特币程序的。也把它kill掉吧。以下是脚本内容。<br /><img alt="" src="http://www.blogjava.net/images/blogjava_net/writegull/redis6.png" /><br /><br />10.通过cat /etc/passwd命令可以看到有一个叫作syss的非法用户，权限还很高，跟root一样，删掉他吧，这是黑客入侵后方便进入的。使用命令userdel -f syss 强制删除一个用户，哪怕他正在登录。<br /><img alt="" src="http://www.blogjava.net/images/blogjava_net/writegull/redis7.png" height="280" width="723" /><br /><br />11.去/mnt目录上，可以看到黑客挂载了很多程序，删除他们吧。<br /><img alt="" src="http://www.blogjava.net/images/blogjava_net/writegull/redis8.png" /><br /><br />12.通过nethogs软件可以按进程实时统计网络带宽利用率，这个用来看是否存在DDOS攻击最好不过了。<br /><br />13.暂时解决对外DDOS攻击，最快的办法就是用防火墙，这个阿里云提供的脚本帮了大忙。直接上传到服务器上，运行一下世界就清静了。下载地址：<div><a target="_blank" href="https://help.aliyun.com/knowledge_detail/5973920.html?&amp;utm_campaign=sys&amp;utm_medium=system&amp;utm_source=sys_email&amp;msctype=email&amp;mscmsgid=107915121500486146&amp;spm=5176.7618386.5.1.H8H33f">https://help.aliyun.com/knowledge_detail/5973920.html?spm=5176.7618386.5.1.H8H33f</a><br /><br />&nbsp;</div><img src ="http://www.blogjava.net/writegull/aggbug/428651.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/writegull/" target="_blank">writegull</a> 2015-12-15 01:13 <a href="http://www.blogjava.net/writegull/archive/2015/12/15/428651.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse Removing obsolete files from server 问题 </title><link>http://www.blogjava.net/writegull/archive/2015/01/03/422014.html</link><dc:creator>writegull</dc:creator><author>writegull</author><pubDate>Sat, 03 Jan 2015 08:58:00 GMT</pubDate><guid>http://www.blogjava.net/writegull/archive/2015/01/03/422014.html</guid><wfw:comment>http://www.blogjava.net/writegull/comments/422014.html</wfw:comment><comments>http://www.blogjava.net/writegull/archive/2015/01/03/422014.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/writegull/comments/commentRss/422014.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/writegull/services/trackbacks/422014.html</trackback:ping><description><![CDATA[今天在修改server.xml调试程序时，遇到下面这个问题，clean，重启都不好使。<br /><br /><div>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Removing obsolete files from server..<br /> <div><wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;Could not clean server of&nbsp;obsolete files: null<br /> &nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;<wbr><wbr>&nbsp;java.lang.NullPointerException<br /></div></div>解决方法是把.metadata\.plugins\org.eclipse.wst.server.core这个目录下面的tmp0删除掉，再clean下就可以了。可能是缓存问题。<img src ="http://www.blogjava.net/writegull/aggbug/422014.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/writegull/" target="_blank">writegull</a> 2015-01-03 16:58 <a href="http://www.blogjava.net/writegull/archive/2015/01/03/422014.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>禁用UIButton且不会使按钮变得半透明</title><link>http://www.blogjava.net/writegull/archive/2013/12/23/407906.html</link><dc:creator>writegull</dc:creator><author>writegull</author><pubDate>Mon, 23 Dec 2013 02:29:00 GMT</pubDate><guid>http://www.blogjava.net/writegull/archive/2013/12/23/407906.html</guid><wfw:comment>http://www.blogjava.net/writegull/comments/407906.html</wfw:comment><comments>http://www.blogjava.net/writegull/archive/2013/12/23/407906.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/writegull/comments/commentRss/407906.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/writegull/services/trackbacks/407906.html</trackback:ping><description><![CDATA[<span style="color: #454545; font-family: tahoma, helvetica, arial; font-size: 14.399999618530273px; line-height: 16.799999237060547px; background-color: #ffffff;">有时候需要手动地去禁用一个uibutton,使用button.enabled = NO的时候虽然能够达到目的但也会带来副作用，那就是按钮变的半透明了。有时候应用不需要这种副作用，可以尝试使用button.userInteractionEnabled = NO来达到这个目的，在禁用按钮的同时也不会使得按钮变得半透明。</span><img src ="http://www.blogjava.net/writegull/aggbug/407906.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/writegull/" target="_blank">writegull</a> 2013-12-23 10:29 <a href="http://www.blogjava.net/writegull/archive/2013/12/23/407906.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>win8占cpu高</title><link>http://www.blogjava.net/writegull/archive/2013/03/18/396621.html</link><dc:creator>writegull</dc:creator><author>writegull</author><pubDate>Mon, 18 Mar 2013 14:47:00 GMT</pubDate><guid>http://www.blogjava.net/writegull/archive/2013/03/18/396621.html</guid><wfw:comment>http://www.blogjava.net/writegull/comments/396621.html</wfw:comment><comments>http://www.blogjava.net/writegull/archive/2013/03/18/396621.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/writegull/comments/commentRss/396621.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/writegull/services/trackbacks/396621.html</trackback:ping><description><![CDATA[装win8后发现cpu占用率50%-60%，而且磁盘疯狂读写，是com surrogate这个程序，还有几个服务造成的，之后我把com surrogate结束进程了cpu使用率直接降低到10%以下，我就郁闷了。<br />解决方案：<br />1，在&#8220;更多电脑设置&#8221;那里的&#8220;用户&#8221;改为&#8220;本地用户&#8221;。<br />2，&#8220;离开&#8221;家庭组（一般都是它的原因）<br />3，&#8220;同步设置&#8221;关<br />4，一般&#8220;共享&#8221;什么的不到需要都是&#8220;关&#8221;的状态。<br />5，做完以上几点都不行，就真帮不了你了。<img src ="http://www.blogjava.net/writegull/aggbug/396621.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/writegull/" target="_blank">writegull</a> 2013-03-18 22:47 <a href="http://www.blogjava.net/writegull/archive/2013/03/18/396621.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFMessageComposeViewController或MFMailComposeViewController 在IOS6下不显示键盘的问题</title><link>http://www.blogjava.net/writegull/archive/2012/10/30/390482.html</link><dc:creator>writegull</dc:creator><author>writegull</author><pubDate>Tue, 30 Oct 2012 13:08:00 GMT</pubDate><guid>http://www.blogjava.net/writegull/archive/2012/10/30/390482.html</guid><wfw:comment>http://www.blogjava.net/writegull/comments/390482.html</wfw:comment><comments>http://www.blogjava.net/writegull/archive/2012/10/30/390482.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/writegull/comments/commentRss/390482.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/writegull/services/trackbacks/390482.html</trackback:ping><description><![CDATA[这个问题似乎只有在手动改变系统状态栏级别的情况才会出现<br /><br />例如：self.window.windowLevel = UIWindowLevelStatusBar+1;<br /><br />这样设置的话相当于影响了弹出短信或邮件控制器页面window的级别，所以造成不显示键盘问题（不过此问题在ios6以下没有）<br /><br />解决方法：在当前视图控制器中加入下面的代码，即可解决<br /><p>- (void) viewDidAppear:(BOOL)animated {</p> <p>&nbsp; &nbsp; [super viewDidAppear:animated];</p> <p>&nbsp; &nbsp; self.window.windowLevel = UIWindowLevelNormal;</p> <p>}</p><img src ="http://www.blogjava.net/writegull/aggbug/390482.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/writegull/" target="_blank">writegull</a> 2012-10-30 21:08 <a href="http://www.blogjava.net/writegull/archive/2012/10/30/390482.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>xcode 4 制作静态库详解</title><link>http://www.blogjava.net/writegull/archive/2012/10/09/389260.html</link><dc:creator>writegull</dc:creator><author>writegull</author><pubDate>Tue, 09 Oct 2012 10:14:00 GMT</pubDate><guid>http://www.blogjava.net/writegull/archive/2012/10/09/389260.html</guid><wfw:comment>http://www.blogjava.net/writegull/comments/389260.html</wfw:comment><comments>http://www.blogjava.net/writegull/archive/2012/10/09/389260.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/writegull/comments/commentRss/389260.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/writegull/services/trackbacks/389260.html</trackback:ping><description><![CDATA[<p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">原文地址:<a href="http://blog.csdn.net/pjk1129/article/details/7255163">http://blog.csdn.net/pjk1129/article/details/7255163</a><br /><br />最近在做Apple的IOS开发，有开发静态库的需求，本身IOS的开发，只允许静态库或者Framework。在Xcode上没有找到允许编译，如同Android上的*.so和Win32上的dll这样的说法。不过Framework这样的框架，估计也是类似动态库的实现，不过没有具体研究过，后续继续深入研究。</p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">我这个文档的静态库的开发是基于Xcode4.2和iOS SDK5.0编写的。Xcode4跟之前的Xcode3还是有不少的差别的。<br style="line-height: normal; " /><br style="line-height: normal; " />下面就简单写一个静态库和一个调用静态库的例子。<br style="line-height: normal; " /><br style="line-height: normal; " />静态库的编写：<br style="line-height: normal; " /><br style="line-height: normal; " /><span style="font-size: 24px; ">1.静态库工程的建立：</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">Xcode New一个新的project，选择IOS下面的Framework&amp;Library，下面有一个Cocoa Touch Static Library。直接next去建立一个<span style="font-family: Menlo; color: #ff3f47; ">Print</span>这样的工程。</p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><img src="http://hi.csdn.net/attachment/201202/13/0_1329118362Vtyi.gif" alt="" style="border: none; " /><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><span style="font-size: 24px; ">2.工程建立</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">我们添加很简单的"- (void)printA;"和"+&nbsp;(void)printB;"的方法，这个方法的实现也是很简单的，在*.m文件中的实现就是一个"NSLog（@&#8220;&#8221;);"这样我们编译出来的libstaticlib就可以被其他的IOS工程进行调用了。这块注意一下，目前我们的<span style="color: #ff6666; ">Print-&gt;iOS Device</span><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><span style="color: #ff6666; "><img src="http://hi.csdn.net/attachment/201202/13/0_13291189031ll1.gif" alt="" style="border: none; " /><br /></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><span style="color: #ff6666; "><br /></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><span style="font-size: 24px; ">3.编译前准备</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">这里分release与debug版本，需要设置一下</p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><img src="http://hi.csdn.net/attachment/201202/13/0_1329119666ASG0.gif" alt="" style="border: none; " /><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><span style="font-size: 24px; ">4.OK，编译</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">我们可以在Products下面找到我们编译生成的libstaticlib.a这个文件。<br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">注意未编译前为红色：左 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 编译后为黑色：&nbsp;右<br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><img src="http://hi.csdn.net/attachment/201202/13/0_13291197545597.gif" alt="" style="border: none; " />&nbsp; &nbsp; &nbsp; &nbsp;<img src="http://hi.csdn.net/attachment/201202/13/0_1329119760thsk.gif" alt="" style="border: none; " /><br /></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="font-size: 24px; ">5.ok</span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; ">在右边&nbsp;这个文件上右键Open In Finder。这时候我们打开了一个文件夹，里面有一个<span style="color: #6652cc; ">libPrint.a</span>。后面我们继续编写一个调用这个<span style="color: #6652cc; ">libPrint.a</span>的App。但是这个App在编译时候会出错，通过这个错误的解决，说明Xcode的一些编译相关的东西。这里，我们在command下面根据路径找到这个文件，用这个非常重要的命令查看一下这个lib的信息！</p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; ">打开终端写入如下命令：<span style="color: #ff0000; ">这是什么？这就是所在的路径&nbsp;</span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; ">以下均是在自己的mac上的路径。你需要将<span style="color: #0055ff; ">/Users/pjk1129/Library/Developer/Xcode/DerivedData/Print-dgfkluumuexoxhcapzidtsmdgqcj/Build/Products/&nbsp;</span><span style="color: #ff0000; "><span style="color: #000000; ">替换成你的路径。</span></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #0055ff; ">cd&nbsp;</span>/Users/pjk1129/Library/Developer/Xcode/DerivedData/Print-dgfkluumuexoxhcapzidtsmdgqcj/Build/Products/&nbsp;&nbsp;</p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; ">我们手动打开这个路径：可以看到如下信息：Release-iphoneos</p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><br /></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #6652cc; ">这个是给真机用的，那我们要给模拟器和真机封装的静态库应该都能用才好。这个下面介绍！！！！！ &nbsp;</span><br /></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #6652cc; "><img src="http://hi.csdn.net/attachment/201202/13/0_1329120126mZUU.gif" alt="" style="border: none; " /><br /></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "></p><p style="font-family: Arial; background-color: #ffffff; color: #6652cc; line-height: normal; ">然后再在终端&nbsp;打开这个文件：<span style="color: #ff0000; ">cd&nbsp;/Users/user/Library/Developer/Xcode/DerivedData/UItab-dbvoszbzpavyglaboxgflvrnzfce/Build/Products/Debug-iphoneos</span></p><p style="font-family: Arial; background-color: #ffffff; color: #6652cc; line-height: normal; ">命令是：lipo -info libPrint.a，可以看到显示的结果是：Arch是&nbsp; Arm7。下面我会具体介绍一下。</p><p style="font-family: Arial; background-color: #ffffff; color: #6652cc; line-height: normal; "><img src="http://hi.csdn.net/attachment/201202/13/0_13291203125yEc.gif" alt="" style="border: none; " /><br /></p><p style="font-family: Arial; background-color: #ffffff; color: #6652cc; line-height: normal; "><span style="font-size: 24px; ">6.建立一个调用这个libPrint.a的应用</span></p><p style="font-family: Arial; background-color: #ffffff; color: #6652cc; line-height: normal; ">应用就很简单了，我们添加刚才libPrint.a的*.h文件。&nbsp;然后在这个工程的Build Phases的Link Binary With Library里面添加我们刚才拷贝出来的那个libPrint.a。<br /></p><p style="font-family: Arial; background-color: #ffffff; color: #6652cc; line-height: normal; "><img src="http://hi.csdn.net/attachment/201202/13/0_1329120524m42u.gif" alt="" style="border: none; " /><br /></p><p style="font-family: Arial; background-color: #ffffff; color: #6652cc; line-height: normal; "><br /></p><p style="font-family: Arial; background-color: #ffffff; color: #6652cc; line-height: normal; "><span style="font-size: 24px; ">7.插入了h和a文件后</span></p><p style="font-family: Arial; background-color: #ffffff; color: #6652cc; line-height: normal; ">我们就可以在control里面调用这个libPrint.a&nbsp;函数了。<br /></p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">#import "AstroDiskAppDelegate.h"</p><span style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">#import "Print.h"</span><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "></p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; min-height: 16px; "><br /></p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">@implementation AstroDiskAppDelegate</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; min-height: 16px; "><br /></p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">@synthesize window = _window;</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; "><br /></p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">- (void)dealloc</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">{</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">&nbsp; &nbsp; [_window release];</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">&nbsp; &nbsp; [_viewController release];</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">&nbsp; &nbsp; [super dealloc];</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">}</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; min-height: 16px; "><br /></p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">{</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; min-height: 16px; ">&nbsp;&nbsp; &nbsp;</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">&nbsp; &nbsp; //<span style="font-family: 'Heiti SC Light'; ">调用</span>libPrint.a</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">&nbsp; &nbsp; [Print printB];</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">&nbsp; &nbsp; Print&nbsp; *print = [[[Print alloc] init] autorelease];</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">&nbsp; &nbsp; [print printA];</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; min-height: 16px; "><br /></p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">&nbsp; &nbsp; self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">&nbsp; &nbsp; [self.window makeKeyAndVisible];</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">&nbsp; &nbsp; return YES;</p><p style="color: #333333; background-color: #ffffff; margin: 0px; line-height: normal; font-family: Menlo; ">}</p><div style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "></div><br style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; " /><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="font-size: 24px; "><span style="color: #6652cc; ">8.OK，编译运行这个应用程序。</span></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #6652cc; ">编译出现错误了。这个就是这篇文档的关键了。主要就是为了介绍编译静态库相关的东西。<br /></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #6652cc; "><img src="http://hi.csdn.net/attachment/201202/13/0_1329120855M0XV.gif" alt="" style="border: none; " /><br /></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #6652cc; "><br /></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="font-size: 24px; "><span style="color: #6652cc; ">9.可以看到undefine symbols for architecture i386这样的错误。</span></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #6652cc; ">其实这个错误原因很简单，就是因为，我们用错了编译出来的libUITab.a&nbsp;lib，在模拟器里面，我们需要的是基于i386构架编译的static lib，但是这个a文件，大家还记得前面说的arm6 arm7构架的么。这个a其实是在iphone这个arm构架上运行的代码。其实show in finder指向的是一个ios device的库，并不是i386模拟器下的库。那如何编译i386的库呢？<span style="color: #0055ff; ">看见第二张图片的Print&gt;IOS Device了么</span>？我们将这个iOS Device修改成iPhone5.0&nbsp;Simulator。在进行编译，这样就可以编译出i386下面的库。这个时候我们show in finder打开的文件夹还是ios device下的库。我们最好自己去那个目录下看一下。这里我们用command去查看了一下目录情况，如下：可以看到一个iphoneos的目录和一个simulator的目录。<br /></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #6652cc; "><br /></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #6652cc; ">然后我们再看看这个目录与第4条所示的目录有什么不同！ 同样也有一个libPrint.a文件。<br /></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #6652cc; "><img src="http://hi.csdn.net/attachment/201202/13/0_1329121014MZzs.gif" alt="" style="border: none; " /><br /></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #6652cc; "><br /></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="font-size: 24px; "><span style="color: #6652cc; ">10.错误原因分析</span></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="color: #6652cc; ">Release-iphoneos里面的是基于arm6 arm7编译出来的库文件。Release-iphonesimulator文件夹下面的是基于i386编译出来的文件。</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><span style="font-size: 24px; "><span style="line-height: 20px; "><span style="line-height: normal; ">11.</span>合并.a文件，制作通用静态库</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><span style="line-height: 20px; ">这二个库一个是用于真机运行的一个是用于模拟器运行的.<span style="line-height: normal; ">其实我们可以利用lipo将这二个文件打包成一个通用的a文件。命令如下：<br /></span></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; ">将<span style="color: #ff0000; ">/Users/user/Library/Developer/Xcode/DerivedData/UITab-dgfkluumuexoxhcapzidtsmdgqcj/Build/Products<span style="color: #000000; ">替换成你的路径。&nbsp;</span></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; ">将<span style="color: #0055ff; ">/Users/user/Desktop/libPrint.a<span style="color: #000000; ">替换成合并后的路径。&nbsp;</span></span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; ">lipo -create /Users/pjk1129/Library/Developer/Xcode/DerivedData/Print-dgfkluumuexoxhcapzidtsmdgqcj/Build/Products/Release-iphonesimulator/libPrint.a &nbsp;/Users/pjk1129/Library/Developer/Xcode/DerivedData/Print-dgfkluumuexoxhcapzidtsmdgqcj/Build/Products/Release-iphoneos/libPrint.a &nbsp;-output /Users/pjk1129/Desktop/libPrint.a</p><br style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; " /><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><span style="font-size: 24px; ">12.打包以后的库文件，我们查看信息</span></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; ">然后打入如下命令：lipo -info /Users/pjk1129/Desktop/libPrint.a&nbsp;</p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; ">可以看到如下信息：<br /></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><img src="http://hi.csdn.net/attachment/201202/13/0_1329121555f9hD.gif" alt="" style="border: none; " /><br />如上，你已经看到了，它具备了i386和arm7的条件。&nbsp;现在我们这个静态库，支持的构架已经是armv7 i386了。<br /></p><p style="color: #333333; font-family: Arial; background-color: #ffffff; line-height: normal; "><br /></p><span style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><span style="font-size: 24px; ">13.ok，经过上述步骤后</span></span><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; ">这个通用库生成后，我们将原来，调用这个库进行替换一下，在进行编译，成功编译，运行结果如下所示：</p><p style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><img src="http://hi.csdn.net/attachment/201202/13/0_13291217270t2z.gif" alt="" style="border: none; " /><br /></p><div></div><img src ="http://www.blogjava.net/writegull/aggbug/389260.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/writegull/" target="_blank">writegull</a> 2012-10-09 18:14 <a href="http://www.blogjava.net/writegull/archive/2012/10/09/389260.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>three20 Debugging 讲解</title><link>http://www.blogjava.net/writegull/archive/2012/09/27/388664.html</link><dc:creator>writegull</dc:creator><author>writegull</author><pubDate>Thu, 27 Sep 2012 02:30:00 GMT</pubDate><guid>http://www.blogjava.net/writegull/archive/2012/09/27/388664.html</guid><wfw:comment>http://www.blogjava.net/writegull/comments/388664.html</wfw:comment><comments>http://www.blogjava.net/writegull/archive/2012/09/27/388664.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/writegull/comments/commentRss/388664.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/writegull/services/trackbacks/388664.html</trackback:ping><description><![CDATA[three20 wiki 地址:https://github.com/facebook/three20/wiki/Debugging<br /><div id="head" style="margin: 14px 0px 5px; padding-top: 5px; padding-bottom: 5px; border-width: 0px 0px 1px; border-bottom-style: solid; border-bottom-color: #cccccc; overflow: hidden; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 12px; line-height: 14px; background-color: #ffffff; "><h1>Debugging</h1><ul readability-extra"="" style="margin: 6px 0px 0px; padding: 0px; border: 0px; float: right; list-style-type: none; overflow: hidden; "><li style="margin: 0px 0px 0px 7px; padding: 0px; border: 0px; float: left; "><a href="https://github.com/facebook/three20/wiki/Debugging/_history" bigger=""  action-page-history"="" style="margin: 0px; padding: 0px 10px; border-width: 1px; border-style: solid; border-color: #d4d4d4 #d4d4d4 #bcbcbc; color: #333333; text-decoration: none; position: relative; display: inline-block; font-size: 13px; font-weight: bold; line-height: 24px; white-space: nowrap; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; cursor: pointer; -webkit-user-select: none; text-shadow: #ffffff 0px 1px 0px; background-image: -webkit-linear-gradient(top, #fafafa, #eaeaea); ">Page History</a></li></ul></div><div id="wiki-content" style="margin: 0px; border: 0px; color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 12px; line-height: 14px; background-color: #ffffff; "><div style="margin: 0px; border: 0px; "><div id="wiki-body"  instapaper_body"="" style="margin: 0px; border: 0px; "><div style="margin: 0px; border: 0px; font-size: 14px; line-height: 1.6; "><p style="margin: 0px 0px 15px; padding: 0px; border: 0px; ">You can use Three20's debugging facilities instead of&nbsp;<code style="margin: 0px 2px; padding: 0px 5px; border: 1px solid #eaeaea; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">NSLog()</code>&nbsp;/&nbsp;<code style="margin: 0px 2px; padding: 0px 5px; border: 1px solid #eaeaea; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">assert()</code>. This would give you an ability to turn off debugging messages without commenting out all&nbsp;<code style="margin: 0px 2px; padding: 0px 5px; border: 1px solid #eaeaea; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">NSLog</code>'s, sort log messages by importance (<code style="margin: 0px 2px; padding: 0px 5px; border: 1px solid #eaeaea; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">error</code>,&nbsp;<code style="margin: 0px 2px; padding: 0px 5px; border: 1px solid #eaeaea; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">warning</code>,&nbsp;<code style="margin: 0px 2px; padding: 0px 5px; border: 1px solid #eaeaea; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">info</code>).</p><h1>Turn on debugging（打开调试）</h1><p style="margin: 0px 0px 15px; padding: 0px; border: 0px; ">These instructions are for Xcode 3:</p><ul style="margin: 15px 0px; padding: 0px 0px 0px 30px; border: 0px; "><li style="margin: 0px; padding: 0px; border: 0px; ">Right-click on project, choose "Get Info".</li><li style="margin: 0px; padding: 0px; border: 0px; ">In the "Build" tab, choose "Configuration =&gt; Debug" (you probably want to enable this only for debug builds)</li><li style="margin: 0px; padding: 0px; border: 0px; ">While in the "Build" tab, search for "Preprocessor Macros" under the "GCC 4.2 - Preprocessing" section.<ul style="margin: 0px; padding: 0px 0px 0px 30px; border: 0px; "><li style="margin: 0px; padding: 0px; border: 0px; ">Add a declaration that reads&nbsp;<code style="margin: 0px 2px; padding: 0px 5px; border: 1px solid #eaeaea; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">DEBUG</code>. That way you enable debugging in general.</li><li style="margin: 0px; padding: 0px; border: 0px; ">Add a declaration that reads&nbsp;<code style="margin: 0px 2px; padding: 0px 5px; border: 1px solid #eaeaea; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">TTMAXLOGLEVEL=TTLOGLEVEL_INFO</code>. By doing this, you set the default debugging output to be<code style="margin: 0px 2px; padding: 0px 5px; border: 1px solid #eaeaea; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">TTLOGLEVEL_INFO</code>, the most descriptive one.</li></ul></li></ul><p style="margin: 15px 0px; padding: 0px; border: 0px; "><img src="https://a248.e.akamai.net/camo.github.com/48dde704cd3a001e4dbc35dca4f24727f28d84e6/687474703a2f2f692e696d6775722e636f6d2f52697154412e706e67" alt="Debugging preprocessor macro" style="margin: 0px; padding: 0px; border: 0px; max-width: 100%; " /></p><h1>Use debugging</h1><h2>Logging</h2><p style="margin: 0px 0px 15px; padding: 0px; border: 0px; ">Use these instead of&nbsp;<code style="margin: 0px 2px; padding: 0px 5px; border: 1px solid #eaeaea; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">NSLog()</code>. Which level gets printed to the console and which doesn't depends on what's set in preprocessor macros as<code style="margin: 0px 2px; padding: 0px 5px; border: 1px solid #eaeaea; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; white-space: nowrap; background-color: #f8f8f8; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">TTMAXLOGLEVEL</code>&nbsp;(see above).</p><div style="margin: 0px; border: 0px; "><pre style="margin-top: 15px; margin-bottom: 15px; padding: 6px 10px; border: 1px solid #cccccc; font-size: 13px; font-family: Consolas, 'Liberation Mono', Courier, monospace; background-color: #f8f8f8; line-height: 19px; overflow: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; "><span style="margin: 0px; padding: 0px; border: 0px; ">TTDERROR</span><span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; ">text</span><span style="margin: 0px; padding: 0px; border: 0px; ">,</span> <span style="margin: 0px; padding: 0px; border: 0px; ">...)</span>    <span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">//</span> <span style="margin: 0px; padding: 0px; border: 0px; ">Log</span> <span style="margin: 0px; padding: 0px; border: 0px; ">level</span> 1 <span style="margin: 0px; padding: 0px; border: 0px; ">TTDWARNING</span><span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; ">text</span><span style="margin: 0px; padding: 0px; border: 0px; ">,</span> <span style="margin: 0px; padding: 0px; border: 0px; ">...)</span>  <span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">//</span> <span style="margin: 0px; padding: 0px; border: 0px; ">Log</span> <span style="margin: 0px; padding: 0px; border: 0px; ">level</span> 3 <span style="margin: 0px; padding: 0px; border: 0px; ">TTDINFO</span><span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; ">text</span><span style="margin: 0px; padding: 0px; border: 0px; ">,</span> <span style="margin: 0px; padding: 0px; border: 0px; ">...)</span>     <span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">//</span> <span style="margin: 0px; padding: 0px; border: 0px; ">Log</span> <span style="margin: 0px; padding: 0px; border: 0px; ">level</span> 5 <span style="margin: 0px; padding: 0px; border: 0px; ">TTDPRINT</span><span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; ">text</span><span style="margin: 0px; padding: 0px; border: 0px; ">,</span> <span style="margin: 0px; padding: 0px; border: 0px; ">...)</span> </pre></div><h3>Example</h3><p style="margin: 0px 0px 15px; padding: 0px; border: 0px; ">If I got this in&nbsp;<em style="margin: 0px; padding: 0px; border: 0px; ">AppDelegate.m</em>&nbsp;of my project&nbsp;<em style="margin: 0px; padding: 0px; border: 0px; ">HelloWorld</em>:</p><div style="margin: 0px; border: 0px; "><pre style="margin-top: 15px; margin-bottom: 15px; padding: 6px 10px; border: 1px solid #cccccc; font-size: 13px; font-family: Consolas, 'Liberation Mono', Courier, monospace; background-color: #f8f8f8; line-height: 19px; overflow: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; "><span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">-</span> <span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; color: #445588; font-weight: bold; ">void</span><span style="margin: 0px; padding: 0px; border: 0px; ">)</span><span style="margin: 0px; padding: 0px; border: 0px; color: #990000; font-weight: bold; ">applicationDidFinishLaunching:</span><span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; ">UIApplication</span> <span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">*</span><span style="margin: 0px; padding: 0px; border: 0px; ">)</span><span style="margin: 0px; padding: 0px; border: 0px; color: #008080; ">application</span> <span style="margin: 0px; padding: 0px; border: 0px; ">{</span>	     <span style="margin: 0px; padding: 0px; border: 0px; ">TTDINFO</span><span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; color: #dd1144; ">@"Hello!"</span><span style="margin: 0px; padding: 0px; border: 0px; ">);</span> <span style="margin: 0px; padding: 0px; border: 0px; ">}</span> </pre></div><p style="margin: 15px 0px; padding: 0px; border: 0px; ">...the console output would look like this:</p><pre style="margin-top: 15px; margin-bottom: 15px; padding: 6px 10px; border: 1px solid #cccccc; font-size: 13px; font-family: Consolas, 'Liberation Mono', Courier, monospace; background-color: #f8f8f8; line-height: 19px; overflow: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; "><code style="margin: 0px; padding: 0px; border: none; font-size: 12px; font-family: Consolas, 'Liberation Mono', Courier, monospace; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; ">2010-05-15 01:04:20.107 HelloWorld[65222:207] -[AppDelegate applicationDidFinishLaunching:](22): Hello! </code></pre><h2>Conditional logging</h2><p style="margin: 0px 0px 15px; padding: 0px; border: 0px; ">This is a type of logging facility which only outputs something if a particular condition is met:</p><div style="margin: 0px; border: 0px; "><pre style="margin-top: 15px; margin-bottom: 15px; padding: 6px 10px; border: 1px solid #cccccc; font-size: 13px; font-family: Consolas, 'Liberation Mono', Courier, monospace; background-color: #f8f8f8; line-height: 19px; overflow: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; "><span style="margin: 0px; padding: 0px; border: 0px; ">TTDCONDITIONLOG</span><span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; ">condition</span><span style="margin: 0px; padding: 0px; border: 0px; ">,</span> <span style="margin: 0px; padding: 0px; border: 0px; ">text</span><span style="margin: 0px; padding: 0px; border: 0px; ">,</span> <span style="margin: 0px; padding: 0px; border: 0px; ">...);</span> </pre></div><h3>Example</h3><div style="margin: 0px; border: 0px; "><pre style="margin-top: 15px; margin-bottom: 15px; padding: 6px 10px; border: 1px solid #cccccc; font-size: 13px; font-family: Consolas, 'Liberation Mono', Courier, monospace; background-color: #f8f8f8; line-height: 19px; overflow: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; "><span style="margin: 0px; padding: 0px; border: 0px; ">TTDCONDITIONLOG</span><span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; ">TTDFLAG_URLREQUEST</span><span style="margin: 0px; padding: 0px; border: 0px; ">,</span> <span style="margin: 0px; padding: 0px; border: 0px; color: #dd1144; ">@"Request parameters: %@"</span><span style="margin: 0px; padding: 0px; border: 0px; ">,</span> <span style="margin: 0px; padding: 0px; border: 0px; ">request</span><span style="margin: 0px; padding: 0px; border: 0px; ">.</span><span style="margin: 0px; padding: 0px; border: 0px; ">parameters</span><span style="margin: 0px; padding: 0px; border: 0px; ">);</span> </pre></div><h2>Debug-only assertions</h2><p style="margin: 0px 0px 15px; padding: 0px; border: 0px; ">Three20 also provides support for assertions which only work in the debug build.</p><div style="margin: 0px; border: 0px; "><pre style="margin-top: 15px; margin-bottom: 15px; padding: 6px 10px; border: 1px solid #cccccc; font-size: 13px; font-family: Consolas, 'Liberation Mono', Courier, monospace; background-color: #f8f8f8; line-height: 19px; overflow: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; "><span style="margin: 0px; padding: 0px; border: 0px; ">TTDASSERT</span><span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; ">condition_which_would_lead_to_application_termination_when_true</span><span style="margin: 0px; padding: 0px; border: 0px; ">);</span> </pre></div><h3>Example</h3><div style="margin: 0px; border: 0px; "><pre style="margin-top: 15px; margin-bottom: 15px; padding: 6px 10px; border: 1px solid #cccccc; font-size: 13px; font-family: Consolas, 'Liberation Mono', Courier, monospace; background-color: #f8f8f8; line-height: 19px; overflow: auto; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; "><span style="margin: 0px; padding: 0px; border: 0px; color: #999988; font-style: italic; ">// Not that implementing safeAddSubview: is a good idea</span> <span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">-</span> <span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">void</span><span style="margin: 0px; padding: 0px; border: 0px; ">)</span><span style="margin: 0px; padding: 0px; border: 0px; ">safeAddSubview:</span><span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; ">UIView</span><span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">*</span><span style="margin: 0px; padding: 0px; border: 0px; ">)</span><span style="margin: 0px; padding: 0px; border: 0px; ">view</span> <span style="margin: 0px; padding: 0px; border: 0px; ">{</span>     <span style="margin: 0px; padding: 0px; border: 0px; color: #008080; ">TTDASSERT</span><span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; ">nil</span> <span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">!=</span> <span style="margin: 0px; padding: 0px; border: 0px; ">view</span><span style="margin: 0px; padding: 0px; border: 0px; ">);</span>     <span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">if</span> <span style="margin: 0px; padding: 0px; border: 0px; ">(</span><span style="margin: 0px; padding: 0px; border: 0px; ">nil</span> <span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">==</span> <span style="margin: 0px; padding: 0px; border: 0px; ">view</span><span style="margin: 0px; padding: 0px; border: 0px; ">)</span> <span style="margin: 0px; padding: 0px; border: 0px; ">{</span>         <span style="margin: 0px; padding: 0px; border: 0px; font-weight: bold; ">return</span><span style="margin: 0px; padding: 0px; border: 0px; ">;</span>     <span style="margin: 0px; padding: 0px; border: 0px; ">}</span>     <span style="margin: 0px; padding: 0px; border: 0px; ">[</span><span style="margin: 0px; padding: 0px; border: 0px; ">self</span> <span style="margin: 0px; padding: 0px; border: 0px; ">addSubview:</span><span style="margin: 0px; padding: 0px; border: 0px; ">view</span><span style="margin: 0px; padding: 0px; border: 0px; ">];</span> <span style="margin: 0px; padding: 0px; border: 0px; ">}</span> </pre></div><h1>See also</h1><ul style="margin: 15px 0px; padding: 0px 0px 0px 30px; border: 0px; "><li style="margin: 0px; padding: 0px; border: 0px; "><a href="https://github.com/facebook/three20/blob/master/src/Three20Core/Headers/TTDebug.h" style="margin: 0px; padding: 0px; border: 0px; color: #4183c4; text-decoration: none; ">Three20Core/Headers/TTDebug.h</a></li><li style="margin: 0px; padding: 0px; border: 0px; "><a href="https://github.com/facebook/three20/blob/master/src/Three20Core/Headers/TTDebugFlags.h" style="margin: 0px; padding: 0px; border: 0px; color: #4183c4; text-decoration: none; ">Three20Core/Headers/TTDebugFlags.h</a></li></ul><h1>Links</h1><ul style="margin-top: 15px; margin-right: 0px; margin-bottom: 0px !important; margin-left: 0px; padding: 0px 0px 0px 30px; border: 0px; "><li style="margin: 0px; padding: 0px; border: 0px; "><a href="http://three20.info/article/2010-10-07-Debugging-With-Three20" style="margin: 0px; padding: 0px; border: 0px; color: #4183c4; text-decoration: none; ">Debugging on three20.info</a></li></ul></div></div></div></div><img src ="http://www.blogjava.net/writegull/aggbug/388664.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/writegull/" target="_blank">writegull</a> 2012-09-27 10:30 <a href="http://www.blogjava.net/writegull/archive/2012/09/27/388664.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>将旧的推送通知从通知中心移除掉</title><link>http://www.blogjava.net/writegull/archive/2012/09/14/387745.html</link><dc:creator>writegull</dc:creator><author>writegull</author><pubDate>Fri, 14 Sep 2012 09:51:00 GMT</pubDate><guid>http://www.blogjava.net/writegull/archive/2012/09/14/387745.html</guid><wfw:comment>http://www.blogjava.net/writegull/comments/387745.html</wfw:comment><comments>http://www.blogjava.net/writegull/archive/2012/09/14/387745.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/writegull/comments/commentRss/387745.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/writegull/services/trackbacks/387745.html</trackback:ping><description><![CDATA[<p style="background-color: #fef3dd; border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; color: #292929; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 17px; ">翻译:http://www.joshsunshine.me.uk/2012/02/29/ios-development-remove-old-notifications-from-notification-center.html</p><p style="background-color: #fef3dd; border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; color: #292929; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 17px; ">不逐字翻译了，只是大体说一下。<br />看作者的意思，应该是他经常收到N多通知，而通过其中一条通知打开一个app以后，发现那个app的其它通知还在通知中心。作者不喜欢这样的情况。我以为我也存在的这样的情况，马上检查了一下，发现没有。看来是少数app的问题。但是也记录一下。作者总结的从通知中心移除通知的三种方法：<br />1.将app的BadgeNumber设为0，就是app图标右上角那个</p><div text=""  default"="" style="background-color: #f1f1f1; border: 1px solid #9f9f9f; margin: 0px 0px 10px; vertical-align: baseline; font-size: 13px; line-height: 1.4em; font-family: Monaco, 'Lucida Console', monospace; overflow: auto; white-space: nowrap; width: 740px; "><div codecolorer"="" style="border: 0px; margin: 0px; padding: 5px; vertical-align: baseline; line-height: 1.4em; ">[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];</div></div><p style="background-color: #fef3dd; border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; color: #292929; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 17px; "><br />2.如果BadgeNumber本身就是0的情况，可以先将其设1再设置成0</p><div text=""  default"="" style="background-color: #f1f1f1; border: 1px solid #9f9f9f; margin: 0px 0px 10px; vertical-align: baseline; font-size: 13px; line-height: 1.4em; font-family: Monaco, 'Lucida Console', monospace; overflow: auto; white-space: nowrap; width: 740px; "><div codecolorer"="" style="border: 0px; margin: 0px; padding: 5px; vertical-align: baseline; line-height: 1.4em; ">[[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];<br style="line-height: 1.4em; " />[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];</div></div><p style="background-color: #fef3dd; border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; color: #292929; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 17px; ">3.如果以上的办法都不好使的话，那就用本地通知欺骗一下。</p><div text=""  default"="" style="background-color: #f1f1f1; border: 1px solid #9f9f9f; margin: 0px 0px 10px; vertical-align: baseline; font-size: 13px; line-height: 1.4em; font-family: Monaco, 'Lucida Console', monospace; overflow: auto; white-space: nowrap; width: 740px; "><div codecolorer"="" style="border: 0px; margin: 0px; padding: 5px; vertical-align: baseline; line-height: 1.4em; ">UIApplication* application = [UIApplication sharedApplication];<br style="line-height: 1.4em; " />NSArray* scheduledNotifications = [NSArray arrayWithArray:application.scheduledLocalNotifications];<br style="line-height: 1.4em; " />application.scheduledLocalNotifications = scheduledNotifications;</div></div><p style="background-color: #fef3dd; border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; color: #292929; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 17px; ">就这么多了，我仔细想了一下，为什么我的应用从其中一条通知打开的时候，其它的通知消失掉：<br />因为我在程序启动的时候就执行了第一条:)</p><img src ="http://www.blogjava.net/writegull/aggbug/387745.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/writegull/" target="_blank">writegull</a> 2012-09-14 17:51 <a href="http://www.blogjava.net/writegull/archive/2012/09/14/387745.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFMessageComposeViewController 界面语言问题</title><link>http://www.blogjava.net/writegull/archive/2012/09/10/387412.html</link><dc:creator>writegull</dc:creator><author>writegull</author><pubDate>Mon, 10 Sep 2012 10:12:00 GMT</pubDate><guid>http://www.blogjava.net/writegull/archive/2012/09/10/387412.html</guid><wfw:comment>http://www.blogjava.net/writegull/comments/387412.html</wfw:comment><comments>http://www.blogjava.net/writegull/archive/2012/09/10/387412.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/writegull/comments/commentRss/387412.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/writegull/services/trackbacks/387412.html</trackback:ping><description><![CDATA[<span style="font-family: Verdana; font-size: 13px; line-height: normal; background-color: #ffffff; ">使用MFMessageComposeViewController 编写发短信模块时界面是英文的情况下，用下面的方法可以解决问题</span><br /><span style="font-family: Verdana; font-size: 13px; line-height: normal; background-color: #ffffff; "><br />在plist里面Localization native development region 选择 china ，然后Localized resources can be mixed 选 YES，如果没有Localized resources can be mixed，需手动添加</span><img src ="http://www.blogjava.net/writegull/aggbug/387412.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/writegull/" target="_blank">writegull</a> 2012-09-10 18:12 <a href="http://www.blogjava.net/writegull/archive/2012/09/10/387412.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>