当收到新邮件时向Gtalk发送提醒消息

by 李喆 2012.1.16 17:20
 最近工作中需要双屏都用在Mac上写代码,但是邮件的收取是在windows上,有时会有漏收邮件的情况发生。用C#写了一个小工具,当收到新邮件时向指定的Gtalk账户发信息,用到了agsXMPP这个开源项目

using System;
using System.Collections.Generic;
using System.Text;
using agsXMPP;
using agsXMPP.protocol.client;
using System.Threading;
using System.IO;
using Microsoft.Office.Interop.Outlook;
namespace sendmessage
{
    class Program
    {
        static void Main(string[] args)
        {
            outLookApp = new ApplicationClass();
            outLookApp.NewMailEx += new ApplicationEvents_11_NewMailExEventHandler(outLookApp_NewMailEx);
            Console.WriteLine("Please wait for new messages...");
            Console.ReadLine();
        }
 
        static void outLookApp_NewMailEx(string EntryIDCollection)
        {
            foreach (string item in EntryIDCollection.Split(','))
            {
                NameSpace outlookNS = outLookApp.GetNamespace("MAPI");
                MAPIFolder mFolder =
                  outLookApp.Session.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
                Console.WriteLine("Message send...");
                MailItem mailItem = (MailItem)outLookApp.Session.GetItemFromID(item, mFolder.StoreID);
 
                message = mailItem.Subject + " from <" + mailItem.SenderName + ">" + "\n" + mailItem.Body;
                Console.WriteLine(message);
 
                gtalkid = File.ReadAllText("gtalkid.txt"); // 接受消息的账户
                connection = new XmppClientConnection();
                connection.Server = "gmail.com";
                connection.ConnectServer = "talk.google.com";
                connection.Username = "用户名"; // 用来发送消息的账户
                connection.Password = "密码";
                connection.OnLogin += new ObjectHandler(connection_OnLogin);
                connection.Open();
            }
        }
 
        static void connection_OnLogin(object sender)
        {
            connection.Send(new agsXMPP.protocol.client.Message(gtalkid, MessageType.chat, message));
            Console.WriteLine("Please wait for new messages...");
        }
 
        static XmppClientConnection connection;
        static string gtalkid;
        static ApplicationClass outLookApp;
        static string message;
    }
}
 

Tags:

工作小记

【转】程序猿装B指南

by 李喆 2011.12.20 14:14
 文章来自http://sighlife.com/75.html

最近似乎装B指南比较火,我们程序猿也来装B吧.

一.准备工作

“工欲善其事必先利其器。”

1.电脑不一定要配置高,但是双屏是必须的,越大越好,能一个横屏一个竖屏更好。一个用来查资料,一个用来写代码。总之要显得信息量很大,效率很高。 
2.椅子不一定要舒服,但是一定要可以半躺着。 
3.大量的便签,各种的颜色的,用来记录每天要完成的事务,多多益善。沿着电脑屏幕的边框,尽量贴满,显出有很多事情的样子。 
4.工具书,orelly的,机械工业,电子工业什么的都可以,能英文就英文,不行影印版的也可以,反正越厚越好,而且千万不要放在书架上,一定要堆在桌上,半打开状。

 

二.从进门开始

0..绝对不10点以前出现在公司. 
1.着装!着装!不管你是去实验室,或者去公司的大楼,在或者是小公司的民宅,或是自己创业的黑作坊;无论是春夏秋冬白天晚上刮风下雨电闪雷鸣台风龙卷风,一个装b的程序员都要十分在意自己着装!这里只提出参考建议。初级装:衬衣+牛仔裤+休闲鞋。中级装:T恤+宽松短裤+拖鞋。高级装:背心+宽松大花裤衩+人字拖。 
2.得体的举止。在走廊以及任何形式的过道里,一定要双手插兜,走得像个痞子,至少要看起来有点反社会,如若不行,可走文弱天才型geek路线。。 
3.如果有女性在你背后指指点点,小声嘀咕说这一定是一个技术男的时候,应该先低头,然后保持低头状态,缓缓回头,坏坏地蔑笑但是不要出声,然后快步前行。 
4.进门后,一定不要跟任何人打招呼,笔直走向自己的位置,最多路过打一杯咖啡,千万不要有多余的动作,显示出自己的专注与心无旁骛。

三.坐下就不要再动了

1.坐下以后,姿势需要略微后仰,能翘着二郎腿最好了,然后在后仰的情况下低着头,以便看到屏幕,然后千万就不要再动了。 
2.粗暴地把电脑前的大堆书推开一个口,然后摘下电脑上的一个便签,看一眼,不过3秒,可以开始coding了。 
3.能不用IDE就不要用,实在装不了,无论IDE是什么,一定要调成DOS那种黑色背景的。 
4.如果写前台界面,就不停地调试后台代码;如果写java,就在里面混编C;如果写C,就在里面混编汇编。不光要coding,还要时不时的翻出一本什么英文的书翻一翻,看不懂就看看插图,然后扔到面前假装懂了继续coding。 
5.什么看起来高端就用什么,不要管实用不实用。例如对C++:switch统统重构成多态;如果有指针,统统改成智能的;C++一定要自己写template;数字是全部要替换成宏的名字能起多长就起多长;struct就不要出现了,如果出现,也一定要用__attribute__修饰一下;运算都是位操作的;操作符都是重载的;网络都是并发缓冲线程池的;int只用int32_t声明的;继承不用普通的,什么多继承虚继承啊;helloworld也要写捕获异常的;后人一看代码,中间一堆关键字extern,asm,auto,XXXXX_cast,volatile,explicit,register,template,让一般总在敲int,if,else,for的小程序员顿时心生崇拜。 
6.注释?算了吧。只有两个路线可以选:一,变量名起得巨长无比,看代码就和读英文文章一样顺畅,根本不需要加注释。 二,代码无比晦涩,加不加注释根本无影响。 
7.千万不要用IM工具交流,千万不要问同事问题,显得自己没有水平,都是自己上网或者查书。 
8.无论是同事间开玩笑或者发生任何群体性事件,不要抬头,更不要东张西望,即使地震火灾,也一定要先提交代码再行离开。

四.潇洒地离开

1.人走,主机是千万千万不能关的,至少要跑个daily build,实在不行正在svn提交也勉强算过关。 
2.书应该已经又堆到屏幕前了,千万不要整理,明天再来推开。 
3.不强求最后一个走,但一定要所有的非程序员,什么市场啊前台啊pm啊都走光了,才可以走。 
4.走得时候一定要率性,千万不要收拾任何东西,站起来,出门,好的,就这样。 
5.如果今天一定要说句话的话,找到那个最苦逼的程序员,跟他说,你进度太慢了啊,不要老让我等你。

Tags:

年底又购置了一些书,列一下书单,包括看过的没看过的没看完的

by 李喆 2011.12.9 11:35
预计今年的能读30本左右,其实有很多书适合多读几遍,有的看一遍就能扔了, 有的书需要仔细研读

Head First 设计模式

程序员修炼之道——从小工到...

代码大全(第二版)

国富论(上)

国富论(下)

资本论(卷一)

资本论(卷二)

资本论(卷三)

南渡北归3:离别

Windows Phone Mango开发实践

C++Primer Plus

失控:全人类的最终命运和结局

FACEBOOK效应

盛世2013

往事并不如烟

ZERR0:世界符号大全

框架设计,第3版(影印版)

南渡北归2:北归

正面抗日战场【第二部】:烽火大地

南渡北归1:南渡

数据结构与算法分析:C语言描述

编程珠玑(2)

编程之美

C++ Primer中文版(4版)

1988——我想和这个世界谈谈

秘密 The Secret

软件架构师应该知道的97件事

金字塔原理(2010年最新修订版)

不可思议的年代:面对新世界必须具备的关键...

正面抗日战场【第一部】:我的家在松花江上...

鲁迅的胡子(蒋一谈短篇小说集)

重新发现社会【修订版】(熊培云亲笔签名本)

《暗时间》(部分签名本随机发货)

《浪潮之巅》(IT巨头们的兴衰之路)

百年孤独(魔幻现实主义文学经典,加西亚·马尔克斯巅峰杰作,中文版全球首次正式授权)

西藏生死书(唯有懂得死亡,才能懂得生命的真谛)

大家都有病(朱德庸教你聪明看世界透明看人生!一本漫画读懂一个时代)

非普通读者(仅西安少量存货)

此时此地(艾未未)

无价(2011年第一奇书,媲美西奥迪尼的《影响力》)

董桥作品:青玉案

董桥作品:记得

我的抗战(崔永元制造,大型电视纪录片同名图书。)

重来(更为简单有效的商业思维)

爱的地下教育(彭浩翔作品,全中国空前凶悍实用的纸本情感Q&A。精装)

深入理解计算机系统(英文版.2)

人月神话(英文版)(图灵奖得主总结软件项...

数学分析 1卷(英文影印版)

数学分析 2卷(英文影印版)

无线通信基础(英文影印版)

乔布斯传

Tags:

困扰我两天的问题终于解决了!!转篇文章

by 李喆 2011.11.6 17:13

Duplicate symbols when linking ObjectiveC static libraries


When you link a static library that’s using ObjectiveC categories, you usually have instructions from the developers to add -ObjC and -all_load linker flags which solve linking problems and prevent crashes. Now, if you happen to have the same categories or other objc symbols in your project that uses this static library you’ll get linker errors for duplicate symbols. The most common example for this is using touch JSON framework. I have this static library that uses it, and I also use it in my own code. I’m running into this linking problem every once in a while so I’m going to explain it here and provide a solution for fixing/avoiding it.

THE PROBLEM

Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

ld: duplicate symbol _OBJC_METACLASS_$_SBJSON in /Users/ivan/Projects/MyApp/sources/Trunk/MyApp/libtest-simulator.a(SBJSON.o) and /Users/ivan/Projects/MyApp/sources/Trunk/MyApp/build/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/i386/SBJSON.o

WARNING: I’ll be talking about problems with touch JSON library because this is the common problem. Solutions may not apply to other libraries although the principle is more-less the same. Be warned.

SCENARIO #1

“My project uses 1 static library and both this library and my project need JSON framework”.

Simplest solution that might work is to remove -ObjC and -all_load linker flags. When I say ‘might’, I mean that you need to be extra careful with this. If you do this, the static library you link will depend on JSON code from your project so if there’s, for example, a version mismatch you’ll run into serious problems.

 

LInker Flags in Xcode

Linker Flags

SCENARIO #2

“My project uses a static library which depends on JSON framework but this library also links other ObjectiveC static libraries. Both my project and this static library need JSON framework”

OR

“I cannot remove -ObjC and -all_load because I need to properly link categories inside a static library, but I also need to add JSON framework to my own project”

Now this is a specific scenario I ran into earlier. I wanted to use Three20 library which links several different ObjC libraries of its own so I definitely need -ObjC and -all_load flags otherwise my app crashes. On the other hand, I had another static library which uses JSON framework and adding this framework to my project causes duplicate symbols linker error.

The solution is simple again but you also need to be extremely careful. You leave those linker flags to properly link ObjC libraries but you don’t add JSON framework in your project. Instead you depend on JSON library linked with the static library you are using. You will, however, need to add header files in order to avoid compilation errors in your own code. Possible problem here is header files vs. compiled code in the static library mismatch. So you need to make sure that the JSON header files you’re using match the JSON code version linked with the static library. If you already imported JSON framework, just remove .m files in XCode from your target.

 

JSON framework xcode

JSON framework files

 

BOTTOMLINE

Obviously, these are some rare cases of linking problems however, JSON touch framework is a very popular framework and it’s not uncommon that some 3rd party libraries you want to use are built on top of it. My final advice is to understand the problem and why it happens, then you will be able to solve it one way or the other. Good luck!


Tags:

代码段 | 工作小记

这帮人26岁时在干嘛呢?

by 李喆 2011.9.7 08:35
1、邓小平26岁时,领导百色起义,创建中国工农红军第七军、第八军。

2、毛泽东26岁时,在湖南创建共产主义组织,并参加革命。

3、周恩来26岁时,巴黎回国归来,在黄埔军校任政治部主任,国民革命军第一军政治部主任。

4、蒋介石26岁时,在参加二次革命,并加入中华革命党。

5、曹操26岁时,担任洛阳北部尉,相当于北京市副公安局局长。

6、周瑜26岁时,已经当任建威中郎将,地方高级将领。

7、诸葛亮26岁时,被刘备三顾茅庐,出山从政。

8、美国总统林肯26岁时,已经通过自学成为律师,并被选为州议员。

9、奥巴马26岁时,在哈佛大学的法学院读博士。

10、胡锦涛26岁时,在水电部刘家峡工程局房建队劳动。

11、温家宝26岁时,在甘肃省地质局地质力学队当技术员。

12、周杰伦26岁时,已经凭《七里香》红遍大江南北,并在同年拍了《头文字D》。

13、王石26岁时,在兰州铁道学院读本科。

14、潘石屹26岁时,去海南开办了自己的房地产企业,在海南的房地产泡沫中大赚一笔。

15、柳传志26岁时,在广东珠海白藤农场劳动锻炼,并于同年进入中科院计算技术研究所任助理研究员。

16、成龙26岁时,已经拍了N多电影。并于2年后成功进入好莱坞市场。

17、李鸿章26岁时,已经考中二甲第十三名进士,相当于全国第26名,并写下了“一万年来谁著史,三千里外欲封侯”的名句。

18、曾国藩26岁时,在不断考公务员,不过运气很差,科举屡次不中,2年后中进士。

19、胡雪岩26岁时,在小钱庄当伙计。10年后,终于开了自己的银行——阜康钱庄。

20、盛宣怀26岁时,通过招聘进入李鸿章手下当幕府。3年后开办轮船招商局,成为洋务运动的核心人物。

21、李白26岁时,通过倒插门,娶了前宰相许围师的孙女,并生下一男一女。

22、杜甫26岁时,不无正业,在全国巡回旅游。史书记载“客吴越、齐赵间”,后有“举进士不中第,困长安”,考公务员也没考上,工作也不好找,后来被皇帝发现了,才有好日子过了。

23、唐伯虎26岁时,在家里发奋读书,三年后省公务员考试得第一名,即中“解元”。

24、巴菲特26岁时,成立了巴菲特联合有限公司,他仅仅出资100美元,而其他7位合伙人则出资105000美元。他狂妄的说:要在30岁之前成为百万富翁,否则就从奥马哈最高的建筑上跳下去。事实证明,他确实做到了。

25、格林斯潘26岁时,已经获得经济学硕士学位,这一年他结婚了,估计还没有找到正式工作。不过2年后他加入汤森公司,不到5年,就拥有该公司一半股权,并出任总裁。

26、索罗斯26岁时,带着他的全部积蓄5000美元,在纽约当了一名套利交易员。17年后,他创立的量子基金。

27、马克思26岁时,会见了恩格斯,并完成了《哲学经济学手稿》,1年后被法国政府驱逐出境。

28、恩格斯26岁时,和马克思在布鲁塞尔创建共产主义通迅委员会,1年后发表著名的《共产主义宣言》。

29、列宁26岁时,在彼得堡创立了彼得堡工人解放协会,年底被捕入狱,并被流放到西伯利亚。

30、斯大林26岁时,参加革命活动而被捕7次,多次被流放和监禁,所以他不是在革命就是在坐牢。斯大林的意思叫做“铁人”,果然名不虚传。

31、普京26岁时,在苏联的克格勃当特工,从事神秘的对外情报局工作。

32、叶挺26岁时,在孙中山陆海军大元帅府警卫团第二营营长。

33、彭德怀26岁时,在湘军当任连长或营长。

34、萨科奇26岁时,在当律师,2年后当选讷伊市市长。

35、克林顿26岁时,在耶鲁大学法学院攻读法学博士,4年后出任阿肯色州司法部长。

36、布什26岁时,在得克萨斯国民警卫队空军担任战斗机飞行员。

37、尼克松26岁时,在加利福尼亚州惠特尔当律师。

38、关羽26岁时,应该在卖红枣。

39、朱元璋26岁时,参加红巾军起义,并成为该军事力量的实际领导人。

40、成吉思汗26岁时,在为统一草原而战斗。

41、爱迪生26岁时,发明了2重电报机。10年后他发明了灯泡。

42、比尔盖茨26岁时,已经创立微软公司6年了。39岁就成为了世界首富。

43、贝多芬26岁时,听力失聪,但是他扼住了命运的咽喉,最终5年后创作了著名的《命运交响曲》。

44、黄光裕26岁时,已经创办国美电器3年了,这一年国美电器连锁店已经开了10家。

45、张朝阳26岁时,在美国麻省理工学院攻读博士学位。

46、牛根生26岁时,任内蒙古伊利集团(原呼和浩特回民奶食品厂)厂长。

47、马化腾26岁时,在当软件工程师,1年后创办腾讯计算机系统有限公司。

48、张艺谋26岁时,在陕西咸阳国棉八厂当工人。

49、袁隆平26岁时,在湖南安江农校教书。

50、李喆26岁时,在一家公司做软件工程师,这一年是2011年,不要灰心。

Tags:

Mac OS X下配置kinect驱动程序

by 李喆 2011.8.15 20:47
 我的系统版本是lion,中间遇到些小问题,但还好解决,配置起来还算方便,用到了openkinect这个开源项目
下面是具体步骤

1、安装homebrew,在命令行中输入/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)",等待安装完成,具体参考https://github.com/mxcl/homebrew/wiki/installation
2、命令行中输入cd /usr/local/Library/Formula
3、下载文件,命令行中输入curl --insecure -O "https://github.com/OpenKinect/libfreenect/raw/master/platform/osx/homebrew/libfreenect.rb
                                                  curl --insecure -O "https://github.com/OpenKinect/libfreenect/raw/master/platform/osx/homebrew/libusb-freenect.rb
       有时下载不正确,需要验证下文件内容
4、开始安装openkinect,命令行中输入brew install libfreenect
5、喝口水
6、测试一下,命令行中输入glview
继续研究

Tags: , ,

kinect

随机生成指定长度字符串

by 李喆 2011.8.11 11:34
感觉blog上放些代码段也无伤大雅,生成测试数据时用到的方法

 char * randstring(int in_len) 

  char *__r = (char *)malloc(in_len + 1); 

 

  int i; 

 

  if (__r == 0

  { 

    return 0

  } 

 

  srand(time(NULL) + rand());    

  for (i = 0; i  < in_len; i++) 

  { 

    int irand = rand()%50;

    __r[i] = (irand > 25? irand + 7: irand) +65;      

  } 

 

  __r[i] = 0

 

  return __r; 

}

Tags:

iOS5中新增的geocode功能

by 李喆 2011.8.10 21:42
iOS5beta5已经开始趋于稳定,接近发布状态,看来九月初iPhone5发布的消息比较可信,以后打算陆续介绍一些iOS5的开发特性,今天先介绍一个简单的geocode功能。

        先简单介绍一下geocode的概念,我们的设备可以得到当前的坐标信息,但是这个经纬度信息对于用户是没有任何意义的,我们需要在坐标和具体地址之间建立一个映射,geocode的作用就是完成正向和反向的转换。地址转换为坐标称为geocode,坐标转换为地址称为reverseGeocode。
        下面介绍一下iOS5中的geocode,在iOS5中我们可以很方便的利用CLGeocoder类,来进行geocode操作,需要说的是:1、系统会根据当前设备的区域信息返还相符的语言结果,目前支持三十多个国家和地区的语言和地址格式。2、geocode操作是Globle的,不知道朝鲜如何:)。

        使用的时候每发起一个geocode查询,都要新实例化一个CLGeocoder 
         
CLGeocoder *geoCoder = [CLGeocoder new];
        然后定义查询返回时的handle
        
CLGeocodeCompletionHandler gch = ^(NSArray *placemark, NSError *error) {// do something... };
        发起查询
         [geoCoder geocodeAddressString:@”LAX“ completionHandler: gch];
         
         geocode查询提供了以下接口:
          // reverse geocode requests

        - (void)reverseGeocodeLocation:(CLLocation *)location completionHandler:(CLGeocodeCompletionHandler)completionHandler;

 

       // forward geocode requests

       // geocodeAddressDictionary:completionHandler: takes an address dictionary as defined by the AddressBook framework.

       // You can obtain an address dictionary from an ABPerson by retrieving the kABPersonAddressProperty property.

       // Alternately, one can be constructed using the kABPersonAddress* keys defined in <AddressBook/ABPerson.h>.

 

       - (void)geocodeAddressDictionary:(NSDictionary *)addressDictionary completionHandler:(CLGeocodeCompletionHandler)completionHandler;

       - (void)geocodeAddressString:(NSString *)addressString completionHandler:(CLGeocodeCompletionHandler)completionHandler;

       - (void)geocodeAddressString:(NSString *)addressString inRegion:(CLRegion *)region completionHandler:(CLGeocodeCompletionHandler)completionHandler;
注:region的作用,当进行geocode查询时,一个地址可能匹配多个坐标,加入region信息为了取到更精确的结果
效果图如下,经实测,速度比较满意,图中的圆圈范围是为了描述另一个新增功能MonitoringForRegion,通过这个功能可以开发出更多有意思的程序,以后会详细讲。

Tags:

iOS5

[转]So you crashed in objc_msgSend(). Now what?

by 李喆 2011.7.13 10:40
最近正在修改 objc_msgSend()相关的bug,感谢 Greg Parker的文章
原文地址http://www.sealiesoftware.com/blog/archive/2008/09/22/objc_explain_So_you_crashed_in_objc_msgSend.html

Most likely, you sent a message to an already-freed object. Or maybe your pointer is perfectly correct, but someone else mangled the object's contents - perhaps a buffer overrun in a nearby allocation, or use of a dangling pointer that once pointed to the memory now occupied by your object. Occasionally objc_msgSend()crashes because a memory error smashed the runtime's own data structures, but usually the trouble is in the receiver object itself.

Whether you're in the debugger or looking at a crash log, you can recover more information about the crash than just the backtrace.

Receiver and selector registers

objc_msgSend() stores the receiver object and the selector in CPU registers while it works. These values can help diagnose the problem.

The register names differ based on architecture and the objc_msgSend() variant used. This list is correct for Mac OS X Leopard and will probably remain correct for Snow Leopard.

  objc_msgSend
objc_msgSend_fpret
objc_msgSend_stret
  receiver SEL receiver SEL
i386 eax* ecx eax* ecx
x86_64 rdi rsi rsi rdx
ppc r3 r4 r4 r5
ppc64 r3 r4 r4 r5
arm r0 r1 r1 r2
* i386 note: The receiver is in eax for most crashes, but not all. If you manage to get far into objc_msgSend() before falling over, then eax will have some other value.

 

Interpreting the receiver and invalid address

You can use the receiver's address and the invalid address that caused the crash to get some hints about the underlying problem. In a crash log, the receiver's address is in the Thread State using the register name in the table above, and the invalid address is listed at the top (usually something like KERN_PROTECTION_FAILURE at <invalid address>). In the debugger console, the invalid address is printed when the program stops, and you can print the receiver's address using the register name in the table above.

    Program received signal EXC_BAD_ACCESS, Could not access memory.
    Reason: KERN_PROTECTION_FAILURE at address: 0x00000001
    0x00090ec4 in objc_msgSend ()
    (gdb) p/x $eax
    $1 = 0x1
My test program crashed at [(id)1 release]. In real crashes, these values are typically more interesting.

 

Usually, one of two things happens. The receiver address itself is bogus, and the invalid address is the same value (or 16 or 32 bytes away). Or the receiver address is reasonable, and the invalid address is the receiver's isa pointer. The latter is what usually happens if you try to use an already-deallocated object or someone else clobbered your valid object.

Look for special values like these in your crashes. Also look for nearby values; on some architectures, an invalid isa will cause a crash at isa+16 or isa+32 instead.

Not divisble by 16 - misaligned
malloc() returns 16-byte aligned blocks. If your receiver isn't 16-byte aligned, it probably never was a valid object pointer.
Top two and bottom two bits all set - malloc free list
After a block is freed, the memory allocator may write free list pointers into it. If you use a freed object after this, you'll see an isa pointer with the top two and bottom two bits all set.
All bits inverted - GC free list
Like the malloc free list case above, but caused by the garbage collector instead. In this case address looks bad, but ~address is more reasonable.
0xa1b1c1d3 - CF container
CoreFoundation containers use this value for deleted or empty items. Perhaps a freed object has been re-allocated as a container, or someone used a freed container that has been re-allocated as your object, or you read your pointer from a container that was simultaneously changed by some other thread and you don't have the right locks in place.
ASCII text
Perhaps a freed object has been re-allocated as a string, or someone used a freed string that has been re-allocated as your object, or some string operation has a buffer overrun. Use asciify to print these quickly in both endians. This one looks URL-related, for example:
% asciify 0x2e777777
###.www###
###www.###

 

Interrogating the selector

Compiler optimization means the call site pointed to by the second frame in the backtrace might not be the call that actually crashed. It's possible that call succeeded, and then that method made a tail call which was the one that crashed. Because of tail call optimization, the intermediate frame would be missing from the backtrace. We can use the selector register to determine what the real crashing call was.

A selector is a pointer to a unique C string. This may change in future OS versions, but for now it's handy for debugging. If you have crashed in a debugger, open the debugger console and run this, substituting the correct SEL register from the table above:

    (gdb) x/s $ecx
    0xa1029: "release"

 

Snow Leopard's crash reporter adds selector names to crash logs for you:

    Application Specific Information:
    objc_msgSend() selector name: release
Otherwise, retrieving the selector name from just a crash log is difficult and doesn't always work. Until you have Snow Leopard, cross your fingers and try this.
  1. From the crash log's Thread State, find the SEL's value using the register name in the table above.
        ecx: 0x000a1029
  2. From the crash log's Binary Images, find the image whose address range includes the SEL's value. This will often be either the application itself or libobjc.A.dylib. If no image spans that address, give up. 
        0x8b000 -   0x106ff7  libobjc.A.dylib ??? (???) <9b5973b7fa88f9aab7885530c7b278dd> /usr/lib/libobjc.A.dylib
  3. Find a copy of the image that matches the one in the crash log. Use the UUID to verify the match.
        % dwarfdump -u /usr/lib/libobjc.A.dylib
        UUID: 26650299-C6EA-B1C8-52D6-072AC874D400 (ppc) /usr/lib/libobjc.A.dylib
        UUID: 9B5973B7-FA88-F9AA-B788-5530C7B278DD (i386) /usr/lib/libobjc.A.dylib
        UUID: D2A4E8E1-3C1C-E0D9-2249-125B6DD621F8 (x86_64) /usr/lib/libobjc.A.dylib
    This crash matches my installed libobjc.A.dylib for i386. If it's a system library, you may need the image from the OS version listed in the crash log. If it's your application, you did keep a copy of every version you shipped, right?
     
  4. Calculate the SEL's offset into the image.
        0xa1029 - 0x8b000 = 0x16029
  5. Print the C string in the image at that offset. Remember to specify the correct architecture.
        % otool -v -arch i386 -s __TEXT __cstring /usr/lib/libobjc.A.dylib | grep 16029
        00016029  release

Tags:

[转]iPhone、Windows Phone 7界面一一对比

by 李喆 2011.5.11 11:05
 y Morten from Genstart og Rock | Logout 译,转载请注明 ifanr.com 译文链接。

作者在沃达丰从事用户体验相关工作。

首先是锁屏,这是消灭 Tufte 所说界面残渣(interface debris,比如滚动条之类无助于信息显示的界面元素)的第一个例子。整个界面没有任何控件。

要解锁 Windows Phone,只需将整个屏保往上滑。手机就在屏保图片下方。

我还记得当我第一次看见 iPhone 时想:“哦,终于不用再记那些难以理解的按键组合来解锁了”。现在看着 Windows Phone 的解锁机构,让我产生了类似的想法。

w1

————————————————————————————————–

接下来是待机界面。Windows Phone 是动态的。我又回忆起 07 年第一次见到 iPhone 的网格界面,难免有些失望。“就这样?网格?”。Windows Phone 的 Live Tiles 点出了我三年前就期望见到的东西。

w2

————————————————————————————————–

接下来是 People 界面。在我们团队里曾有究竟是否应该在列表中显示照片的热烈讨论。我的观点一直是“没门,没人会通过照片来进行浏览”。看来 Windows Phone 的联系人列表可能会改变我的想法……好吧,它已经改变了。

w3

————————————————————————————————–

联系人详细信息界面是 iPhone 所用 chrome 之多的绝好例子。看看它,这些线条、背景、选框!(译注:chrome在这里是指外观吸引人,但对系统功能无甚帮助的图形元素)

还有个值得注意的地方是,iPhone 似乎觉得数据(电话号码、邮箱地址等)比数据类型(移动电话、家庭电话)更重要;而 Windows Phone 觉得动作更重要(打移动电话、给移动电话发短信……)。Windows Phone 再次赢得了一分。

w4

————————————————————————————————–

Appstore/Marketplace。我无语了(这和 iPhone 的完全相反,有谁真去看那些文字?)

w5

————————————————————————————————–

下面是进入音乐、视频程序后的第一个页面。iPhone 在这里有些优势,它让用户能够直接进行播放操作而不用先在菜单进行选择,然后再操作。不过除此以外,相较而言,iPhone 显得界面元素过载。

w6

————————————————————————————————–

图片程序,Windows Phone 再一次坚持给用户一个入口菜单而不愿让用户直接开始操作。但除此之外嘛,注意 iPhone 列表里的小缩略图和 Windows Phone 所采用的截然不同的显示方法。这毕竟是用来显示图片的程序。

w7

————————————————————————————————–

单幅图片显示。这对 iPhone 有点不太公平,毕竟该界面在用户触碰图片之后才会出现。

但这还是能够说明问题。你有多少时候需要精确知晓相册里到底有几张照片?当你可以用手滑动切换照片的时候需要“上一张”/“下一张”这两个按钮?这里最常用的按钮肯定是“Camera roll”(返回上一级)。

Windows Phone 有一个实体返回按键,这个布局是我强烈反对的。如果你所有交互操作都在屏幕上进行,为什么还要把最常用的那个操作放在屏幕以外?我曾以为 Android 已经证明了我的观点。现在看来,错的可能是我。

w8————————————————————————————————–

上下文菜单非常类似。我知道我又要重复了,不过……Windows Phone 上的界面元素更少。但这里我不确定它是件好事。iPhone 的按钮明确指出了我可以按的区域。在 Windows Phone 上是不是只有按中文字才有效?为了确保按中,我会瞄准文字,这就缩小了点击区域,违背了 Paul Fitts 法则。(译注:在触控环境下,简单地说,目标越小,就越难点中。)

w9————————————————————————————————–

现在先这样吧,分析 iPhone 怎么突然显得过时是件很有意思的事。

有个需要注意的地方,iPhone 的用户界面以及其内部几乎所有的页面都有三年的历史。还有一点,我们还不知道 Windows Phone 在不同手机上的响应速度如何,hub 和内嵌功能能不能应付日常使用。(不过根据上手视频,原型机的响应速度还不错)。

根据 iPad 的界面分析,iPhone OS 4 应该没什么突破。那么,或许微软在新千年里终于领先了一次。

最后是用户界面中的多和少的另一个例子(Lotus VS iCal 2009):

w10

 

Tags:




Calendar

<<  January 2012  >>
MonTueWedThuFriSatSun
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345

在日历中查看文章

Statistics

37 篇文章
2 个单页
440 条评论
27 次评分
91402 次访问
访问统计开始于 2010年7月12日
平均日访问 161 次
当前 4 人在线