Strange Objects (NSCFType, etc.) Indicate Memory Management Bugs.

Strange Objects (NSCFType, etc.) Indicate Memory Management Bugs.

Any errors involving NSCFType or some class you have never heard of (eg ”*** -[NSCFType count]: selector not recognized “) are indicators of a memory management bug. Most likely an object is getting released too soon. The freed memory is then re-allocated for a new object, say an NSCFType. The pointer to the over-released object, obj, has not changed, but is now pointing to a NSCFType, which receives any messages sent to obj (and chokes on most of them).

NSCFType is not documented anywhere by Apple. As near as I can tell, it’s some deep-dark part of Core Foundation, but whatever it really is, it’s clearly not meant to venture out of it’s deep-dark lair. So seeing it means something is very wrong.

Any “selector not recognized” message may also be the result of an early-release. I have had cases where over-released memory was reallocated as anNSString, or other ubiquitous class. However, the vast majority of my “selector not recognized” issues were caused by explicitly sending the wrong message to an object (invoking count on an NSString for example).

EDITED TO ADD: In addition to NSCFType I have also seen memory bee recycled as NSExtraMIData.

Original publish: http://imlocation.wordpress.com/2007/09/13/strange-objects-nscftype-indicate-memory-management-bugs/

iOS5 切换中文键盘时覆盖输入框的完美解决方案

copy from http://www.apkbus.com/blog-107838-44715.html

众所周知,iOS5之前,iPhone上的键盘的高度是固定为216.0px高的,中文汉字的选择框是悬浮的,所以不少应用都将此高度来标注键盘的高度(包括米聊也是这么做的)。

可是在iOS5中,键盘布局变了,尤其是中文输入时,中文汉字选择框就固定在键盘上方,这样就使得原本与键盘紧密贴合的界面视图被中文汉字选择框给覆盖住了。一方面影响了界面的美观,另一方面,如果被覆盖的部分就是文本输入框的话,用户就无法看到输入的内容了。因此这个问题就必须得解决了。

解决方法

其实在一开始使用216.0px这个固定值来标注键盘的高度就是错误的。因为在iOS3.2以后的系统中,苹果就提供了键盘使用的API以及Demo程序——“KeyboardAccessory”。

处理键盘事件的正确方法是这样的:(包括获取键盘的位置以及键盘弹出和消失动画的时间)

1)在要使用键盘的视图控制器中(既viewDidLoad中),接收键盘事件的通知:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

// 键盘高度变化通知,ios5.0新增的
#ifdef __IPHONE_5_0
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version >= 5.0) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil];
}
#endif

2)然后添加键盘事件的处理代码:

获取到当前keyboard的高度以及动画时间,然后对视图进行对应的操作即可。

#pragma mark –
#pragma mark Responding to keyboard events
– (void)keyboardWillShow:(NSNotification *)notification {

/*

Reduce the size of the text view so that it’s not obscured by the keyboard.

Animate the resize so that it’s in sync with the appearance of the keyboard.

*/

NSDictionary *userInfo = [notification userInfo];

// Get the origin of the keyboard when it’s displayed.

NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];

// Get the top of the keyboard as the y coordinate of its origin in self’s view’s coordinate system. The bottom of the text view’s frame should align with the top of the keyboard’s final position.

CGRect keyboardRect = [aValue CGRectValue];

// Get the duration of the animation.

NSValue *animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];

NSTimeInterval animationDuration;

[animationDurationValue getValue:&animationDuration];

// Animate the resize of the text view’s frame in sync with the keyboard’s appearance.

[UIView animateWithDuration:animationDuration animations:^{

//此处的viewFooter即是你的输入框View

//20为状态栏的高度

self.viewFooter.frame = CGRectMake(viewFooter.frame.origin.x, keyboardRect.origin.y-20-viewFooter.frame.size.height,viewFooter.frame.size.width, viewFooter.frame.size.height);

} completion:^(BOOL finished){

}];

}

– (void)keyboardWillHide:(NSNotification *)notification {

NSDictionary* userInfo = [notification userInfo];

NSValue* aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];

CGRect keyboardRect = [aValue CGRectValue];

/*

Restore the size of the text view (fill self’s view).

Animate the resize so that it’s in sync with the disappearance of the keyboard.

*/

[UIView animateWithDuration:0 animations:^{

self.viewFooter.frame = CGRectMake(viewFooter.frame.origin.x, keyboardRect.origin.y-20-viewFooter.frame.size.height, viewFooter.frame.size.width, viewFooter.frame.size.height);

} completion:^(BOOL finished){

}];

}  3)在视图控制器消除时(即viewDidUnload中),移除键盘事件的通知:

[[NSNotificationCenter defaultCenter] removeObserver:self];

背景:

ios5之前,iphone上的键盘的高度是固定为216.0px高的,中文汉字的选择框是悬浮的,所以不少应用都将此高度来标注键盘的高度。

可是在ios5中,键盘布局变了,尤其是中文输入时,中文汉字选择框就固定在键盘上方,这样就使得原本与键盘紧密贴合的界面视图被中文汉字选择框给覆盖住了。一方面影响了界面的美观,另一方面,如果被覆盖的部分就是文本输入框的话,用户就无法看到输入的内容了。因此这个问题就必须得解决了。

解决方法:

其实在一开始使用216.0px这个固定值来标注键盘的高度就是错误的。因为在ios3.2以后的系统中,苹果就提供了键盘使用的api以及demo程序——“KeyboardAccessory”。

处理键盘事件的正确方法是这样的:(包括获取键盘的高度以及键盘弹出和消失动画的时间)

 

1)在要使用键盘的视图控制器中,接收键盘事件的通知:

复制代码
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

        // 键盘高度变化通知,ios5.0新增的  
#ifdef __IPHONE_5_0
        float version = [[[UIDevice currentDevice] systemVersion] floatValue];
        if (version >= 5.0) {
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil];
        }
#endif
复制代码

 

2)然后添加键盘事件的处理代码:

获取到当前keyboard的高度以及动画时间,然后对视图进行对应的操作即可。

复制代码
#pragma mark -
#pragma mark Responding to keyboard events
- (void)keyboardWillShow:(NSNotification *)notification {
    
    /*
     Reduce the size of the text view so that it's not obscured by the keyboard.
     Animate the resize so that it's in sync with the appearance of the keyboard.
     */
    
    NSDictionary *userInfo = [notification userInfo];
    
    // Get the origin of the keyboard when it's displayed.
    NSValue* aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    
    // Get the top of the keyboard as the y coordinate of its origin in self's view's coordinate system. The bottom of the text view's frame should align with the top of the keyboard's final position.
    CGRect keyboardRect = [aValue CGRectValue];
    
    // Get the duration of the animation.
    NSValue *animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
    NSTimeInterval animationDuration;
    [animationDurationValue getValue:&animationDuration];
    
    // Animate the resize of the text view's frame in sync with the keyboard's appearance.
    [self moveInputBarWithKeyboardHeight:keyboardRect.size.height withDuration:animationDuration];
}


- (void)keyboardWillHide:(NSNotification *)notification {
    
    NSDictionary* userInfo = [notification userInfo];
    
    /*
     Restore the size of the text view (fill self's view).
     Animate the resize so that it's in sync with the disappearance of the keyboard.
     */
    NSValue *animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
    NSTimeInterval animationDuration;
    [animationDurationValue getValue:&animationDuration];
    
    [self moveInputBarWithKeyboardHeight:0.0 withDuration:animationDuration];
}
复制代码

3)在视图控制器消除时,移除键盘事件的通知:

[[NSNotificationCenter defaultCenter] removeObserver:self];

ps:

ios5隐藏功能分享——“字典”功能(英英字典):

在任何输入框中选中一个英文单词,此时会有选择项“复制”,“删除”…等,还有一个向右的箭头,点击这个向右的箭头后,就会出现“定义”选项,点击这个“定义”按钮即会弹出这个英语单词的英文解释。

 

 

首先,你得监听键盘的事件,最基本的两个事件:

UIKeyboardWillShowNotification

UIKeyboardWillHideNotification

UIKeyboard…

iOS 5新增加了一些

UIKeyboardDidChangeFrameNotification(will)

一般情况下,前两个事件已经可以完成你要做的事情。在你的事件处理方法中加上NSNotification参数可以为你获得更多的东西:

view plainprint?

– (void)keyboardWillShow:(NSNotification *)notification

{

CGPoint beginCentre = [[[notification userInfo] valueForKey:UIKeyboardCenterBeginUserInfoKey] CGPointValue];

CGPoint endCentre = [[[notification userInfo] valueForKey:UIKeyboardCenterEndUserInfoKey] CGPointValue];

CGRect keyboardBounds = [[[notification userInfo] valueForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];

CGRect keyboardFrames = [[[notification userInfo] valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

UIViewAnimationCurve animationCurve = [[[notification userInfo] valueForKey:UIKeyboardAnimationCurveUserInfoKey] intValue];

NSTimeInterval animationDuration = [[[notification userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];

}

如果你要在程序中使用键盘的高度和宽度,永远不要尝试去手动指定,动态获取也很简单而且一定准确,不会出现键盘

挡住输入框的问题。

你可以利用这些参数把动画做的和键盘一致。假设你要把一个控件放在Window上,并且想让它的交互方式和键盘一样,

如果只是简单的做个向下偏移动画并不能很好的完成,因为你还要考虑从导航栏中Pop出来的时候,这个时候的键盘动画是

在x轴上偏移的,你用UIKeyboardFrameEndUserInfoKey获取的frame可以很准确的做到。

 

如果在某些特殊的字段上,你不想用默认的键盘,而是用类似于Picker这样的拾取器,你只需要设置inputView就行了,用你自定义的视图去替换掉键盘;如果你想在键盘上面再增加一个视图,比如toolbar,那么你可以不用自己对toolbar的位置进行控制,只需要设置inputAccessoryView就行了,这个值默认为nil,设置的视图将在你的控件变成第一响应者的时候显示在inputView的上方。

\\

 

在UIScrollView(UITableView继承于它)上,当你触碰控件使之变成第一响应者的时候,系统会自动调整位置,避免键盘挡住控件。如果在代码中用becomeFirstResponder使之变成第一响应者将不会出现自动调整。你可以设置contentOffset去手动调整。其他视图,最简单的方法就是修改控件的frame属性,让控件总是显示在可见区域。

 

 

IOS键盘事件记

IOS5.0之前不支持键盘sizechange事件(5.0之前键盘尺寸一直保持不变),而5.1居然在键盘size改变时无法正常发出通知。所以要想捕获键盘尺寸变化的事件,可以在键盘didShow事件里通过beginSize和endSize和判断。

 

如果想让UI随着键盘的变化而变化(动画一致),需要在willshow及willhide里加入动画代码。动画的两个参数需要和键盘同步(animationDuration和animationCurve)。

获取键盘的动画参数:

NSDictionary *info = [notification userInfo];

NSTimeInterval duration = 0;

UIViewAnimationCurve curve;

[[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] getValue:&duration];

[[info objectForKey:UIKeyboardAnimationCurveUserInfoKey] getValue:&curve];

 

duration在默认【中文拼音输入法】弹出时,不能正确获取duration,需要加一行代码修正:

duration = (duration > 0 ? duration: 0.25);//已知,IOS5.0.1里面键盘弹出动画的0.25S的,瑕疵:如果这里动画时间不是0.25就有可能动画不同步了

 

【Updated at 2012-05-12】键盘处于显示状态的UIViewController被UINavigationController pop出去时,也会发出 UIKeyboardWillHideNotification通知,只不过这个键盘隐藏的轨迹是【从左到右的滑动】而不是从上到下的收起。所以,如果想在这个通知的响应代码里去调整UI(比如恢复底部工具条的origin.y使其始终居于底部),应该避免横向滑动键盘消失这种情况。可以通过以下响应代码来鉴别是否横向滑动导致键盘消失:

NSDictionary *info = [notification userInfo];

CGPoint kbEndOrigin = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].origin;

if(kbEndOrigtin.x > 0) {//横向滑动导致了键盘消失,不必调整UI

return;

}

//恢复UI显示

分享别人的面经

本文来着Zhengli Sun同学的分享

http://zhengli-sun.blogspot.com/2011/12/cs.html

我的美国CS面试经验分享

过去的一年多里,参加了一些面试,虽然面过的公司不多,但都从头一直走到尾。毕竟自己也是花了大量的时间和精力在这一场场的面试里。所以,就絮叨下自己的一些经验,希望能给在美国找实习找工作的同学们提供一点点帮助。

开始前的一些说明:

1. 笔者只是一介小本科,虽然留了学,但是留了级,学识浅薄,目光短浅,文章若有不恰之处,恳请各位大牛不吝指正!

2. 笔者面试的岗位均为Software Engineer,俗称“程序猿”。如果读者是非CS专业或没有找此类工作的需求,请ctrl + w。本文更多的倾向于CS技术层面,关于面试仪表妆容礼仪等等的其他问题,请出门右拐。

3. 鉴于保密协议,本文只谈面试准备材料和方法,不涉及任何具体面试题。(当然,你如果单独请笔者吃饭,可以考虑)

4. 本文涉及的内容更多地适用于在美国本土的技术面试。美国的面试更加正式规范,国内同学可做适当参考。

5. 个人认为,面试的成功 = 60%的平时积累 + 30%的考前准备 + 10%的其他因素(如自信、谈吐)。所以,面试的准备对于我们这类凡人来说,异常重要;靠平时积累就能虐了面试官的大牛,不在本文考虑之列。

我面过的公司: 百度总部,微软总部,Bloomberg总部,Google总部。

笔者运气较好,除了在微软败在了最后一轮大manager的石榴裙下,其他三家都顺利拿到了offer:先后在百度和Bloomberg实习,并将于明年正式加入Google工作。

下面将分Behavior Question和Technical Question分别介绍个人的面试准备技巧:

I. Behavior Question

这类问题的特点是,易准备,好回答,必出现。所以一定要花几个小时好好准备,写写提纲,面试前对着镜子说几次。

a. HR Question

最无聊的一类问题,比如“why Microsoft?”、“what’s your plan in 5 years? ” 一般为HR所喜欢。

推荐准备材料:http://hrinterviews.blogspot.com/。把这64道题刷一下,所有的HR问题都不会是问题了。准备的方法类似于托福口语,准备几个段子,反复用,就很充分了。

另外,回答一定要真诚。比如,如果被问到“what’s your weakness?”,你如果回答:我太追求完美太热爱工作巴拉巴拉——太过时太恶心人了吧,亲!

b. Talk about your project

一般会在面试的开始被问及,必然会被问到的题目之一。把简历上的项目好好地阐述,辅以画图更佳。一些经典的Follow up是:What is the most challenging part? What will you do if you have opportunities to improve it?

百分一万的准备好这些问题!面试官通常会刨根问底。答的吭吭哧哧,几乎是不诚信的表现。

c. Question for interviewer

一般会在面试的最后十分钟里,面试官会请你提出问题。这是你展现对公司的激情、个人的兴趣、和面试官套近乎等等等等的大好机会。不要说“no”或者仅仅问“啥时知道结果啊,哥们”这类的问题。至少准备五个有深度的问题。

个人经验来说,最好的方法还是随机应变,根据之前面试的情况来合理提问。比如,我在Google的一次面试里,面试官无意间提及他在设计一门新的编程语言。面试最后,我就满脸好奇地说:“talk about your language, please”。然后我和他就编程语言的设计各方面进行了一些小讨论,他最后离开时万分兴奋。就这样,对面试官的尊重,自身兴趣和能力的展现,对技术的激情——一脉相承,水到渠成。

II. Technical Question

技术面试的最核心部分。

下面是一些笔者使用过的材料(请适当支持正版):

•Programming Interviews Exposed

入门级书籍,可以了解一些基本概念。

•Cracking the Coding Interview

中级书籍,经典必备教材,重点推荐,重中之重!从头到尾我做过五次。

•Hacking a Google Interview

MIT的一门课程,教学Handout可作为中级题目练习。

mitbbs的JobHunt板块

资料很多,水帖更多,可以寻找到很多战友和第一手的面经。可以重点学习里面的精华贴。

http://www.sureinterview.com/

中高级的算法题。

http://www.leetcode.com/

高级算法题,难度偏难,可做适当了解。个人认为,如果不是面Google,里面的题目被面到的可能性不高。

Topcoder

知名的编程练习网站,有一些相关的材料和教材很经典。

•面经来源:

mitbbs的JobHunt板块GlassdoorCareerCup

C++ FAQ

非常有名的高级C++语言学习网站。啃下来会很有帮助。主要的目的是为了应付关于Object-Oriented的相关题目。

如果你准备用Java,也请至少把语言使用能力达到中阶。

•Object Oriented Analysis and Design (Oreilly Head First.)和

Design Patterns Oct.2004(Oreilly Head First)

两本OOP的经典教材。据说Design Pattern挺重要,但个人从未遇到过相关题目。但是大致了解一下,总不会错。

•Wikipedia/Google

仔细查阅每一个你所不知道的算法、数据结构和概念,做好笔记。等你在面试时发现一个名词你见过却不知道是什么,你会把肠子悔青的。

•每个公司所关注的技术

这一点非常重要。比如面Google,就要把Distributed System和Information Retrieval的相关技术了解下,好好看看他家的经典Paper:Map-Reduce和Google File System;比如面Bloomberg,对C++的了解和使用一定要啃到一定级别;比如面Amazon,要准备好OOP。

相信我,花六个月的时间,把上述的所有材料搞定,世界上没有哪个技术公司你进不去的。(You know I’m kidding… But it’s basically the fact. )

你可能会问,那如果我只有一周,或者两天,甚至更短的时间去准备一场面试,该怎么办?

我的回答是:第一,如果它是phone interview或者on-campus interview,那只是初级的筛选,难度不会很高,just relax;第二,拿下上述材料中的初级和中级部分(再次强调Cracking the Coding Interview这本书),然后根据公司来决定学习重点,这样就应该有不错的发挥了。毕竟个人积累不同,尽力而为吧。

当你拿到on-site的邀请时,不要去炫耀你的成就了,赶紧去准备之后的面试吧。On-site的难度深度都会有很大的提高。那才是真正的战斗!过不了on-site,你什么也都不是!

下面我会分topic介绍一下准备重点。在你准备面试的过程中,你也应该有一份这样类似的word文档,记录你每天学习到的所有东西。

面试准备绝不是背诵和题海战术,而是能帮助你对CS知识的理解和运用提升到新高度的过程。

1.) Time Complexity分析

基础中的基础。绝大部分情况下,算法的时间复杂度能一眼看出来。

如果是面Google,需要掌握一些严密的时间复杂度的数学推导,有些算法不是一眼能看出时间复杂度的。

2.) Coding

废话!

但是需要练习的是在纸上和在白板上写code。 (不要小看这件事!关掉愚蠢的Eclipse和VC吧)

更关键的是,写的代码要一次成型,bug-free,即使多花点时间。如果你平时有写完代码再慢慢debug的习惯,是很不利的。被面试官找出bug来,你的分数会被大扣分!

语言选择上,C++和Java,抑或 C#,都是无可挑剔的选择——好比,孙权刘备曹操主;

Python,Ruby,Perl啥的也还行,在字符串处理上有奇效,但面试官未必买账,因为有些问题他需要你从底层实现起——貂蝉诸葛主;

啥,你说汇编?——黄盖主!还是开局鞭挞至一血的!

3.) Data Structure

题目类型大多是:给定一些实际需求,来设计相应的数据结构。所以,对每一种数据结构的特点、时间复杂度要非常熟悉,而且要有很敏锐的第一感。

a. Hashtables

可以说是人类发明的最重要的数据结构之一了。面试时的出现率极高!

保证你玩得转Collision strategies和hash function。如果深入到如何设计具体的hash function,题目的难度也会是很大的。

b. Trees

BST,BFS,DFS,trie,Kruskal’s Algorithm ,Prim’s Algorithm

Balanced tree就没什么研究必要了。

c. Graphs:

图的几种储存形式,BFS/DFS,Dijkstra,A* algorithm

d. Linked List/Queue/Stack/Heap

相应操作的时间复杂度要了如指掌。保证你能轻松写出C++ STL或Java Library对应类库的API。

4.) Algorithm

重中之重的重中之重!

Sort,Recursion,Binary Search,Greedy Strategy等等等等要全面准备到。

Dynamic Programming的一些经典题也要会。如果面Google,可能要准备一下DP的高级题目。

笔者认为,准备这类题目毫无捷径,只有不断刷题,总结,刷题,总结。要培养出对题目的直觉,这是一个漫长的训练过程。

在面试的时候,一般来说,要先给面试官提供一个暴力搜索的方法,然后计算复杂度。然后再慢慢做优化。面试时一定要keep talking,提出自己的想法,展现自己的思路。如果你get stuck,面试官也会给出相应的hint(当然这是会被扣分的)。

5.) System Design

常见形式是:给定大数据量和N台机器,解决一个特定的问题。较开放的题目。在网络公司的面试中经常出现。

解法有固定套路,可以参考Cracking the Coding Interview 相关章节,并自己做一些总结和应用。这类题目看起来很难,掌握方法后,实际难度并不算很高,而且容易展现自身的分析能力,容易出彩。当然,面试官很可能会做适当的延伸,涉及到具体的技术,这就靠自身平时的积累见招拆招了。

推荐的一些补充阅读材料:

External Sort (http://en.wikipedia.org/wiki/External_sorting)

Web Crawler (http://nlp.stanford.edu/IR-book/html/htmledition/web-crawling-and-indexes-1.html)

Google MapReduce (http://labs.google.com/papers/mapreduce.html)

Google File System (http://labs.google.com/papers/gfs.html)

6.) Mathematics

重点在于组合数学和概率论。会有一些这类的变体出现。稍微准备准备就可以了,相信国人的数学水平,绝对凌驾于世界巅峰,不管他面试官是阿三还是老美还是欧洲人。

7.) Operating Systems

Processes vs. Threads

Locks, mutexes and semaphores

Deadlock and livelock

Scheduling: FIFO, priority, shortest remaining time, round robin, and multi level.

不算特别重要。至少笔者从未遇过相关题目。

8.) Bit manipulation

两个目的:应付该类面试题(出现率不高,但是Google喜欢问);

用于自己的编程技巧——尽管有些silly,但是在代码中整一点bit manipulation,是很geek的事。

9.) Design Pattern

了解这些:Observer Pattern, Decorator pattern, Factory Pattern, Singleton Pattern

面试是一个很吃经验的考试。不要顾忌前几次的失败,那都是必要的练级。

最后,送上我笃信的一句话:”Success is just like being pregnant. Everybody congratulates you but nobody knows how many times you were fucked”。

谨以此祝愿所有的童鞋都能获得自己Dream Company的offer!

全文完。

Zhengli Sun©2011

How to Give Job-Winning Answers to Interview Questions

This post is copy from http://www.interviewstrategies.com/interview_article_5.html#

Human Resources personnel, professional recruiters and various other career experts all agree: one of the best ways to prepare yourself for a job interview is to anticipate questions, develop your answers, and practice, practice, practice.

There are plenty of websites that offer lists of popular job interview questions, and knowing the types of questions to expect can be very useful. But knowing how to answer those questions can mean the difference between getting the job and getting the “reject letter.”

How to Answer Questions

First, know these important facts:
1. There is no way to predict every question you will be asked during a job interview. In other words, expect unexpected questions–they’ll come up no matter how much preparation you do.

2. Treat any sample answers you find, such as in discussion forums, books or on Internet job sites, as guides only. Do not use any sample answers word for word! Interviewers can spot “canned” answers a mile away, and if they suspect you are regurgitating answers that are not your own, you can kiss that job goodbye. You must apply your own experiences, personality and style to answer the questions in your own way. This is crucial, and it will give you a big advantage over candidates who simply recite sample answers.

3. Job interview questions are not things to fear, they are opportunities to excel. They allow you to show why you are the best person for the job, so instead of dreading them, look forward to them! The key is to give better answers than anyone else, and that’s where your preparation comes in.

Now, take these actions:
1. Make a list of your best “selling points” for the position. What qualifications, skills, experience, knowledge, background, personality traits do you possess that would apply to this particular job? Write them down and look for opportunities to work them into your answers.

2. In addition to any sample job interview questions you find through various resources, you absolutely must develop your own list of probable questions based specifically on the job for which you are applying. Put yourself in the hiring manager’s shoes� what kinds of questions would you ask to find the best person for this job?

3. Write down your answers to likely questions. Study the job announcement carefully. (If you don’t have one, get one!) Note the phrases they use when describing the desired qualifications. You’ll want to target these as much as possible when developing your answers. For example, if the announcement says they want someone with “strong customer service skills,” make sure you include “strong customer service skills” in at least one of your answers. That will make a better impression than saying “I helped customers.”

4. Review and edit your answers until you feel they are “just right.” Read them over and over until you are comfortable that you know them fairly well. Don’t try to memorize them; don’t worry about remembering every word. Practice saying them out loud. If possible, have a friend help you rehearse for the interview.

Here are some more very important tips:

1. Be a (Short) Story Teller
Make use of this old marketing tip: “Facts tell but stories sell.” During a job interview, you are selling yourself. Whenever possible, answer questions with a short story that gives specific examples of your experiences. Notice I said “short.” You don’t want to ramble or take up too much time; you want to be brief but still make your point.

For example, imagine two people interviewing for a job as a dog groomer are asked, “Have you ever dealt with aggressive dogs?” Candidate Joe answers, “Yes, about 10% of the dogs I’ve groomed had aggressive tendencies.” Candidate Mary answers, “Oh yes, quite often. I remember one situation where a client brought in his Pit Bull, Chomper. He started growling at me the moment his owner left, and I could tell from his stance he wasn’t about to let me get near his nails with my clippers. I think he would’ve torn my arm off if I hadn’t used the Schweitzer Maneuver on him. That calmed him down right away and I didn’t have any problems after that.” (I know nothing about dog grooming; I made the Schweitzer Maneuver up for illustrative purposes.)

Don’t you agree that Mary’s answer is better? Sure, Joe answered the question, but Mary did more than that–she gave a specific example and told a quick story that will be remembered by the interviewers.

In today’s job market where there are dozens of highly qualified candidates for each opening, anything you do that will make you stand out and be remembered will greatly increase your odds of getting hired.

2. Keep the Interviewer’s Perspective in Mind; Answer His “What’s in it for Me?” Question
While many questions asked during job interviews appear to focus on your past accomplishments, here’s an important tip: they may be asking about what you did, but what they really want to know is what you can do now, for them.

The key is to talk about your past accomplishments in a way that shows how they are relevant to the specific job for which you are interviewing. Doing advance research about the company (such as at their website or at http://www.hoovers.com) and the position will be extremely helpful.

Here’s another example with Joe and Mary. The interviewer asks, “What is the most difficult challenge you’ve faced, and how did you overcome it?” Joe answers with, “In one job I was delivering pizzas and I kept getting lost. By the time I’d find the address, the pizza would be cold, the customer would be unhappy, and my boss was ready to fire me. I overcame this problem by purchasing a GPS navigation device and installing it in my car. Now I never get lost!” Mary answers, “In my current job at Stylish Hounds, management ran a special promotion to increase the number of customers who use the dog-grooming service. It was a bit too successful because we suddenly had more customers than we could handle. Management would not hire additional groomers to help with the workload. Instead of turning customers away or significantly delaying their appointments, I devised a new grooming method that was twice as fast. Then I developed a new work schedule. Both efforts maximized productivity and we were able to handle the increased workload effectively without upsetting our customers.”

Joe’s answer shows initiative and commitment (he bought that GPS gadget with his own money, after all). But Mary’s answer relates specifically to the job they are applying for (dog groomer). And Mary had done research about the company and discovered it was about to significantly expand it’s dog-grooming operations. So she picked an example from her past that addressed an issue the interviewer was likely to apply to a future situation in his company. See the difference?

Here’s one more example. Joe and Mary are asked, “What’s your greatest accomplishment?” Joe answers, “I won two Olympic Gold Medals during the 2000 Olympics in the high-jump competition.” Mary answers, “I was named Stylish Hounds’s Dog Groomer of the Year in 2003 for increasing productivity in my section by 47%.”

Joe’s accomplishment is pretty spectacular. But remember the interviewer’s perspective. He might be impressed, but he’s thinking “What’s in it for me? What does being a world-class high-jumper four years ago have to do with helping me to increase sales in my dog-grooming department?” Mary’s answer is much less spectacular than Joe’s, but it’s relevant to the position and indicates that she has what it takes to be successful in this particular job. It tells the interviewer, “I have what you’re looking for; I can help you with your specific needs.”

Looks like Mary has a new job!

3. Do Not Lie
Last but not least, tell the truth. It’s sometimes very tempting to “alter” the truth a bit during a job interview. For instance, say you quit instead of being fired. But the risk of being discovered as a liar far outweighs the potential benefit of hiding the truth.

If you are thinking about telling a lie during the interview, ask yourself these questions (this technique has helped me make many major decisions): “What is the best thing that could happen? What is the worst thing that could happen? Is the best thing worth risking the worst thing?” In this instance, the best thing would be getting the job. The worst thing would be getting discovered as a liar, which could lead to getting fired, which could lead to unemployment, which could lead to more job searching, which could lead to another interview, which could lead to the stress of deciding whether to lie about just getting fired, and so on� a cycle that can go on indefinitely. Is all that worth getting the one job, perhaps on a temporary basis?

Always consider the consequences of your actions.

In Summary, Here’s What You Need To Do When Preparing To Answer Job Interview Questions:

1. Study the job announcement.

2. Research the company.

3. Anticipate likely questions.

4. Prepare answers to those questions that are relevant to the position and the company.

5. Promote your best “selling points” (relevant qualifications, capabilities, experience, personality traits, etc.) by working them into your answers.

6. Practice. Practice. Practice.

如何在北美找工作面试

美国面试的问题基本上都是behavioral questions(简单的说就是让你举例子),尤其是在第一轮面试,根本不涉及任何技术性问题,不管你应聘什么样的职位。这也许和那些对技术性及专门知识要求比较强的工作面试有所不同。通过behavioral questions,面试者主要想要了解的是应试者的软性技巧 (soft skills), such as communication skills, personal skills, self-promoting skills and personalities etc. 根据这些了解,面试者给出几个判断:应试者的工作经验和skill set是不是fit这个职位,这个人的沟通技巧是不是足够好,这个人的性格是不是fit公司的文化,是不是一个和同事能team work的人等等。

面试,尤其是第一轮面试,通常是半个小时到一个小时。在这么短的时间里,面试者的考察当然不可能全面,有时甚至是很主观。所以在面试的短暂的时间里,最重要的是展现出自己最适合这个工作的特质,无论是hard skills(经验)还是 soft skills. 有时候,真实的你,真实的话,不一定讨喜,人家不一定愿意听。Fortunately, 越是大公司,越是正规的公司,面试的形式越程序化,越rigid, 所以只要好好准备,摸清了美国公司面试的套路,面试本身就不再是一个可怕的东西。

tips:

1。回答不要啰里啰嗦,没有structure, 没有重点,give too much details。如果一个问题你的回答超过3 – 5 分钟,你就已经死翘翘了。

2。认真听考官的问题。当答完一个问题时,不管答得如何,赶快move on。If you are not sure about the question, ask the interviewer to clarify it.

3。借一本专门指导如何面试的书。 图书馆里有很多种这样的书。先找一本薄一点的,简单一点的,你可以在短时间里读完的。目的是读过以后,你会有一个general idea关于职业面试的概念。然后分析你的具体情况,如果有必要再去找针对性强一些的书或内容。 推荐 “55 Interview Traps”。这本书只有60多页,言简意赅,有很多例子,可读性强。”55 Interview Traps”的下载网址是:http://www.onlinetestprep.com/interview.html。上面一些techniques 在拿到offer的面试中特别有用。一本general interview book 加上 Interview Traps应该可以对面试有一定academic的认识了。剩下的主要任务是do your homework about company research, work on your stories and sharpen your story-telling skills.

2)如何回答behavioral questions?

前面说过behavioral questions是在美国的职业面试当中最常见的形式。通常是面试者抛出一个问题,让你从你的经验当中举出例子。而从你给出的例子当中,面试者得以对你的skills和personalities加以了解和判断。有工作经验的人,尤其是工作时间比较长的人,当然最好举你工作当中的例子。对于那些没有工作经验的人,可以举在学校和同学做project的例子,参加学校社团活动的例子,在community做 volunteer 的例子。

面试中,最常遇见的问题有:

Tell me about your self.

Leadership example

Teamwork example

Project management example

Problem-solving example

Taking initiative example

What’s the most difficult decision you’ve made recently?

Why are you interested in this position/this company?

What do you see yourself five years later in this organization?

关于leadership,我们国人的概念是leader就是领导,就是有一定权力的人,有下属汇报的人。但要知道,有的人在领导的位置上,不一定就有leadership,而有的人不在领导的位置上,但他或她可能在工作当中表现出很好的leadership的素质和能力。英文这个所谓的leadership很抽象,很难具体化。但是,leadership can be demonstrated in different ways.

For example, sometimes, a leader needs to be a change agent. When you initiate something new to change the common practice or the status quo, you have to rationalize your ideas, convince others, motivate them to change, and overcome various obstacles etc. In this case, you are in a leadership role.

Another example. Sometimes, it’d be more difficult to lead people and have them work in concert when they are not reporting you. In my case, as an Export Sales Manager in charge of export sales to China, Japan and Korea, I need internal production, processing and logistic teams to work with me and to insure the production is in place on time, the product quality meets my customer’s requirement and the shipments to my customers are on time. It takes leadership and teamwork skills to get the job done.

Leadership can also be demonstrated in crisis management, for example, when there is a quality problem with your company’s products that may potentially cause a huge loss or negative publicity to your company or your customer. It takes leadership to act fast and decisively, so that the situation would be remedied and the potential damage would be minimized.

Leadership can be also demonstrated when you successfully carry out a project under the challenging timeline or with limited resource, or when you take initiative, identify a potential business opportunity and bring a new revenue stream to the company.

最主要的是不要把leadership理解的很教条和僵化。美国人可以把小小的或看似简单的事情给安上一个漂亮的名字。就象project这个词。只要是有这么一件事情,有一定的objective, 需要人力物力在一定的时间里完成,都可以称之为project. 你完成个作业都可以是个project. 所以你没当过领导不要紧。大家把自己的工作经历和人生经历好好想一想,找出关于leadership的例子应该是不难的。

关于teamwork的问题,有很多varieties. 面试者可能有不同的方式发问。比如:

Give me an example how you work with a team to solve a problem/carry out a project

Give me an example that how you encourage your team members to do their jobs.

Give me an example that how you deal with resistance in a team.

想提醒大家的是,这些例子之间不是mutually exclusive。你可能有一个例子,which may fit different settings, such as leadership, teamwork, project management, problem-solving or initiative-taking. 你也有好几个不同的例子可以展示同一个quality。一般来说,你需要准备至少8 – 10 个例子来回答我列出的这几个topics.

除了Tell me about yourself 这个问题,the most commonly used structure/format to answer behavioral questions is STAR – Situation, Task, Action and Result.

一般来说,对每个问题的回答得控制在2-3分钟以内。在这很短的叙述例子的过程中,你的重点应该是强调Action 和Result,这是面试者最关心的部分。所以在时间分配上,对于Situation和Task你要非常简洁地一笔带过,交代清楚大概的背景就可以了。关于Result, 尽量用数字或百分比来表示。

如果原来工作的行业比较特殊,在面试当中常犯的一个严重错误就是在举例子时,没有把那些行业专业词换成人家能懂的,通用的词。因为人家听不懂,就试图想和人家解释,结果陷入给太多details的泥潭,纠缠在描述Situation 和Task上出不来。一个例子别说2-3分钟,就是5-6分钟也唠叨不清。

所以当你面试的工作是跨行业的,你一定要遏制住欲望,使用那些你耳熟能详的原行业的词或term。人家听不懂至少有两样坏处:听不懂,就没兴趣听了。而且还留下一个印象:你的经验离面试这个行业太远,你不fit。 不管是那种,你的面试已经完了。最好把你所有的例子写下来,严格按照STAR的形式写,然后反复斟酌记忆。有可能的话,找老美改下,要那些写作好的老美改。老美当中也不是每个人都擅长business writing的。面试的时候,千万不要让人感觉你在面无表情的背书。模仿老美讲话,抑扬钝挫,眉飞色舞。

很重要的一点是,你的例子不能用大白话写和说,要用professional business language来写和说。整个面试考察很重要的内容就是你的communication skills. 因为就算你成绩好,技术好,水平高,但你不擅长用business language 来沟通和交流,你的communication skills不好,sooner or later, 你的事业发展会受阻,尤其是在美国,这个非母语的国家。

记得有这样一句话,写得很好。”In business, communications are not only the way that we express ourselves, but also, more importantly, the way that we work with people.”

但如何提高自己的business communication skills 呢?

比如,随身带一个小本子。在日常学习中,读到任何一篇business的东东(可以是课本,case,报纸,公司的宣传材料等等),听到学校讲座里请来的那些公司头头任何一句讲话,只要觉得在我面试当中可以利用上,就把它记下来。现在在面试当中说得很多话,都可以学人家的,靠平时这样积累下来。 俗话说,好记性不如烂笔头。只有记下来,有空就看看,不知不觉你就记住了,那些professional business language就变成了你自己的了,到用的时候就可以随手拈来,运用自如。你如果注意观察一下那些成为公司executive的人,没有一个讲话没有水平的。如果有机会听他们讲话,可以观察他们的谴词造句,他们讲话的structure, the logic behind their speeches,还有他们的body language。还可以在各种场合观察美国人怎么interact, 怎么chitchat。这些技巧不管是在面试当中,还是将来工作当中,都是非常重要的interpersonal skills.

总结下,准备应对面试的那些behavioral questions,是临上轿才扎耳朵眼儿的事情。而提高business communication skills,对于在美国打拼的中国人来说,是需要constant, persistent and life-long efforts,需要learn smart and work smart,才能在美国的职场立于不败之地。

Tell me about yourself

这个问题大概不管你面试什么工作,都是铁定要问到的问题。这个看似简单的问题,实际上是个难对付的问题。通常我们会想,不就是介绍介绍我过去的经验吗,那很容易呀。别人不了解我,难道我还不了解我自己?

但是你有没有想过,既然你简历上已经把你的经验也得很清楚了,why bother面试者要你再复述一遍?所以说,面试者肯定希望听到more than what your resume tells。 他们通过你的叙述,除了工作和生活经验之外,最想知道的是在你made every each transition along the way,是什么原因使你做这个决定的。比如,你换了个工作或行业,why; 你选择来美国读书,why; 你选择读MBA,why?有些公司不错,在问这个问题之前会告诉你,他们对你做的每个决定后面的原因感兴趣。有的公司根本就不告诉你,但他们会expect你在你的回答中告诉他们。

在回答这些原因的时候,you need to be very careful, you need to selectively choose a reason that would make sense from the interviewer’s perspective, not necessarily from your perspective.

在短短几十分钟的面试里,很重要的一项考察内容是soft skills。所以,如果可能的话,在陈述你做过的每一个工作时,简单的summarize what soft kills were developed。如果你有一个很好的progressive track record,随着你的职位升高,你的responsibilities变化,你可以向面试者展示在每个不同阶段你培养的不同的soft skills.

要强调的是,除了谈到你的responsibilities, 千万别忘了讲到results,tangible results。Again,

最好把结果量化,用数字或百分比。用百分比有个好处,有时你的成绩,如销售或节约的成本,合成具体金额可能不那么impressive, 但换算成总销售或总成本的百分比可能就听起来比较厉害。

还有,回答Tell me about yourself,时间最好控制在5-6分钟,不管你有再长的工作经验。就算你有10年的工作经验,你也得在5分钟里面把它讲完。这就需要你用的语言非常concise,需要很好的structure, 需要很流利地把它讲出来。试想,你如果吭吭巴巴,5分钟哪里讲得完。如果你做了若干个工作,但其中一,两个对你的事业发展起到重要的作用,或那些工作经验最接近你现在面试的这个,你需要highlight them,对于其他不重要的可以简单的说一下。

最好就是把你的回答写下来,反复研究修改,使的你的回答达到最简洁有力的程度,需要你大声的读出来,背下来。建议录音,自己听听,有发音问题的让别人纠正下,计算时间,别超时了。有条件的话穿的整整齐齐录像,最能看出自己的各种毛病了。可以和朋友,有经验的人,边看边讨论。俗话说,当局者迷,旁观者清。要不耻下问,不要怕丢丑,旁观者往往能看出你看不出的毛病。这个练习方法也适用于其他behavioral questions。

现在,这里为大家提供一个模版:

I would like to thank everyone for being here and interviewing me. I am going to give you a presentation about my resume.

My name is ~ ~. I got my bachelor degree at XXX University, a top-10 university in China. My major was Japanese. It’s funny that I ended up in the US, instead of Japan.

I got my first job at N Company, which was a top-10 Japanese international trading company. I was working as a sales representative dealing with import/export business between China and Japan. This job brought me a great learning opportunity. I learned how to work with different people, such as importers, exporters, suppliers and customers in both counties. I learned how to negotiate with them, and how to close a deal. My communication and interpersonal skills were developed greatly. During 3.5 years, the business I was in charge of grew from 1.5M to 5M. Then, it reached a point, where I felt that import/export business was too broad and general. I wanted to go to an industry and gain specific industrial knowledge and expertise.

D Corporation presented me with a wonderful opportunity, where I could not only utilize my import/export experience, but also have greater responsibilities, such as strategic implementation and market development. I was reporting directly to the Asia Pacific VP. Since he was based in the U.S. and only visiting China 5-6 times a year, most of time, I was working on my own. It takes initiative, self-management and self-motivation to get the job done. From 1995 to 1999, I successfully implemented strategic plans, commercialized five products in highly regulated markets, recruited five exclusive distributors, and developed a strong distribution network. Sales grew from half million US dollars to 3.4M.

Due to my significant contribution to the company’s bottom-line, I was promoted again from China Office Manager to Export Sales Manager in charge of export sales to China, Japan and Korea. I was transferred from Beijing Office to the company’s headquarters in IL. In the meantime, D Corporation was acquired by M Company. We all became M’s employees.

As an Export Sales Manager, m

How to Prepare for a Behavioral Interview

  1. Study the job description for the position for which you’re interviewing.
  2. Visit the organizations website to gain an understanding of what type of candidate the organization is hiring.
  3. List the personal and professional attributes of the ideal candidate for the job.
  4. Think about which of your experiences can be used to illustrate you have these personal and professional attributes.
  5. Make up questions that demonstrate you have each of these attributes. Behavioral questions usually start with phrases like “Describe a time” and “Tell me about a situation” which force the interviewee to talk about specific experiences.
  6. Develop two or three stories for each personal or professional attribute, using experiences from your past to show you have each attribute.
  7. Try to use the SAR technique to tell these stories. Describe the Situation you were in or problem you were facing at the start of the story. Describe the Action you took or took part in as a result. Then describe the Result of your actions. Spend less time on the Situation and more time on Action and Results. This is what the interviewer cares about.
  8. Practice answering the behavioral interview questions you invented, using the stories you created, so your stories become second nature.

Behavioral Interviews Made Simple

This post is copied from http://work.lifegoesstrong.com/article/behavioral-interviews-made-simple

There are a lot of different ways to conduct an interview.

Some people use the same fixed list of questions for every candidate, others take a more casual go-with-the-flow approach.

Some interviewers are experienced and trying to make you squirm, and others might be more nervous than you are and appreciate you taking control of the conversation.

No matter who you’re talking with, though, you’re likely to get some form of a question that asks you to talk about something you did in the past that will pertain to the job at hand.

These are called behavioral interview questions, and they are probing for specifics about how you handle something the company thinks will be important in that job.

Behavioral questions usually begin by with a phrase like “Tell me about a time when…” or “Describe how you handled a situation when…” and then give you a chance to share about something you’ve done in the past that will give an idea of how you’d do in the job at hand.

Is the behavioral interview dead?

Someone in one of my LinkedIn groups recently put forward a thought that behavioral interview questions were dead. I completely disagree.

Any interviewer worth their salt will ask a candidate to talk about what they’ve done in different situations.

What you did in one situation is a very good indicator of what you’ll do when presented with a similar situation.

Asking someone “What would you do if…” can be helpful to see how someone thinks they might handle something, but asking them for a specific story about a specific situation in the past lets you see how they actually handled it. Behavioral interview questions aren’t going anywhere.

What are some behavioral interview questions?

These are open-ended questions asking you to share something that will show the employer how you’ve handled situations they believe are similar to theirs. For example:

  • Tell me about a time when you had a great deal of pressure and not enough time to get everything done, and how you handled it.
  • Have you ever been in a situation where you didn’t have enough work to keep busy? What did you do?
  • Give me an example of how you set goals and objectives, and how you keep track of your progress.
  • Describe a time when you had to make a difficult decision, and how you made the decision and got other people on board with your choice.
  • Have you ever had a difficult situation with a boss? How did you handle it?

How can you prepare for behavioral interview questions?

One of the challenges of preparing for these questions is that you don’t know exactly what they’ll be asking you about. But that’s OK, because you can prepare a few stories that you can then modify to suit different types of questions.

Here is how to prepare:

1. First, make a list of your key stories from your career.

Begin by making a list of five or six of the most interesting and challenging things you’ve done. This will become your story foundations, to use over and over again.

Did you help convert a software system in the middle of the year, and have to handle everything that went wrong? Did you join a company in financial trouble and have to manage a discouraged work force back to productivity? Are there special projects in your experience that you want to talk about?

2. Once you have your key accomplishments listed, prepare some stories about them to illustrate your ability to solve problems and get things done.

For instance, you can talk about how you recruited others to help with the software conversion, and got your manager to give you budget for hiring extra help. Or you can make notes of how you approached the situation when you realized your new boss had fired the last five people in your job, and you didn’t want to be the sixth.

3. Review the job description and the company to look for hints about what might be important to them.

If the posting really emphasizes attention to detail, make sure your stories show how you notice all the little things. If it emphasizes being able to quickly adapt, make sure you have a story about needing to change direction quickly.

4. Then script your stories out with three parts: situation, action and results.

First, give a sentence that talks about the situation and the challenge you were facing. Next, say what the actions were that you took in that situation, and finally, give the results of your actions.

Make it short and sweet to begin, and leave yourself open for more questions if the interviewer wants you to go deeper with your answer.

5. Adapt the same stories for different situations, and add or subtract details of the specifics.

As an example, here are three different questions, and you can see how the same answer could work for both:

  • Behavioral Question: Tell me about how you have set up a new office from scratch in the past.
  • Behavioral Question: Describe a situation with extremely high expectations, and how you met the challenge.
  • Behavioral Question: Give me an example of how you set goals and meet your objectives.

Answer: When I joined ABC Company in 2004, the CEO was working out of her home and there was no office at all yet. We had a very short timeline and a very limited budget. I called some of my commercial leasing contacts from my previous job, and got leads on several companies who’d had cutbacks so had surplus office space to rent out temporarily. By keeping a very detailed list of what needed to be done, and using my contacts and knowing where to get the best services for the best price, I had us in new quarters within six weeks, including being online, with phones, comfortable desks and all the basic services running.

You can see how you could easily adapt that answer to a question about a demanding boss, a pressing deadline, using contacts to get things done, or many other scenarios. By adding or deleting a few words, you can customize your answer to their question, while still using one of your foundational stories about your work experience to illustrate your abilities.

The behavioral interview question is alive and well, and with a little pre-planning, you’ll make the most of your answer and impress the heck out of the interviewer.