On an iOS interview

Source: Internet
Author: User
<span id="Label3"></p><p><p>Recently found that the Company's platform users are too little, their own technology has reached a bottleneck, it is time to change a user-volume platform, to study the performance optimization of ios, memory optimization and other Issues.</p></p><p><p>The company of the interview due to some of the default rules, not much to say, is roughly an afternoon, from 2 to 6:30 P.M., formally get an offer, first from the pen test start talking about it.</p></p><p><p></p></p><p><p>Written question: 15 questions, a little bit more, done for nearly 1.5 hours. From the written question you can tell a little about the skill level of a Company's iOS team and whether they really want to recruit. I cast a wave of resumes before the spring festival, at that time picked a company to go, not technical side, just see their face test, I know this company will not hire me, because that question is too water, a look is Baidu come over has not screened. After the interview, my interviewer and I said that this set of questions from his entry to the present has not changed, I am hehe, obviously no hiring plan, call me come to a purely waste of time.</p></p><p><p></p></p><p><p>The first way, is the c\oc\c++ inside some common sense, is nil, Null, nil difference</p></p><p><p>This problem I answer is not good, just from the angle of C\oc Grammar explained under their differences, come back under baidu, read the other People's answer, so write:</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">Nil and Null are simple to understand by literal means, Nil is an object, and null is a value, and I understand that nil is set to null, and Null is set to null, and the individual feels a bit like the attribute, the basic type is assigned as assign NSString types are generally assigned copy, whereas objects are generally retain. and we're not going to generate crash or throw exceptions for the nil call Method.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">Nil is an object pointer is empty, nil is a class pointer is empty, NULL is the basic data type is Empty. These can be understood as nil,nil, the difference between Null.</p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">The second way, the similarities and differences between Uievent and Uitouch</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">My answer was that the Uievent object contained a Uitouch object, which was wrong. In the actual development, I often use the touches series api, but basically did not pay attention to uievent Object:</p></p><pre class="brush:objc;gutter:true;"><pre class="brush:objc;gutter:true;">-(void) touchesbegan: (nsset<uitouch *> *) touches withevent: (uievent *) event{ [[touches anyobject] locationInView:self.view];}</pre></pre><p style="margin-left: 60px;"><p style="margin-left: 60px;">Often used so, The main concern is Uitouch object, Google come over, about Uitouch:</p></p><p style="margin-left: 90px;"><p style="margin-left: 90px;">When the User's finger touches the screen, it creates an object associated with the finger, one finger corresponding to a uitouch object, which holds information about the finger, such as the position, time, and stage of the finger Touch.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">Uievent object:</p></p><p style="margin-left: 90px;"><p style="margin-left: 90px;">Each occurrence of an event produces a uievent object, called the event object, that records the time and type of the Event's occurrence.</p></p><p style="margin-left: 90px;"><p style="margin-left: 90px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">The third way, the responder chain, which is a properly delivered sub-question, is not explained in Detail.</p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">fourth, It seems to be about the use of assign\copy\retain\nonatomic\atomic, also is to send sub-problem, it is necessary to note that even if the atomic can not guarantee the thread safety, this I tested, the corresponding information Google under, there should be.</p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">fifth, It seems that why delegate with assign, instead of retain, send sub-problems, do not explain.</p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">The sixth way, that is, when was a autoreleasepool destroyed?</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">If you do not know the Runloop mechanism, it is suggested here that the Autoreleasepool will be destroyed before the thread is destroyed, and a release is done on all objects of the pool Façade.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">The correct answer is that the pool will be destroyed before Runloop enters hibernation, and the pool will be created when the Runloop is awakened, but if you do so, be prepared to ask your interviewer for Runloop related Knowledge.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">第七、八、九、十, basically is the MRC memory management, judge whether correct and error Correction.</p></p><p style="margin-left: 60px; text-align: left;"><p style="margin-left: 60px; text-align: left;">For example:</p></p><pre class="brush:objc;gutter:true;"><pre class="brush:objc;gutter:true;"> NSString *name = [[nsstring alloc] initwithstring:@ "lisi"]; [name retain]; [name release]; [name autorealse];</pre></pre><p style="margin-left: 60px;"><p style="margin-left: 60px;">Need to write down the value of the Reationcount at the beginning, I compare to the first, Autorealse exactly when will be the name of the release operation, and then think about, to carry out the release operation, it must be to this runloop into hibernation, In such a state, runloop does not go into hibernation ...</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">It actually proves that I'm Right: Autorelease actually just delayed the call to release, and for each autorelease, the system just put the object in the current Autorelease pool, and when the pool is released, All object in the pool is called Release. So when did the pool get destroyed? The above topic has already been explained.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">11th, 12, 13, seemingly forget, not to send sub-problems, but there is no great difficulty of the problem, no Impression.</p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">14th, 15, is the algorithm, the 14th, I did not read the meaning of the question?! Read several times, did not understand, the only blank of a topic.</p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">The 15th question, is to combine two ordered linked lists into an ordered list, minutes seconds of it.</p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">On the first side, it should be the iOS owner.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">Probably chatted for nearly two hours, very serious and responsible, the technology is very good. The more impressive interview questions he mentioned:</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">1, runloop, So I took my understanding of Runloop detailed said, roughly is the following things:</p></p><pre class="brush:objc;gutter:true;">Runloop: Run loop, an iOS program from the main function into the Uiapplicationmain,uiapplicationmain opened a runloop, this runloop is the main thread of runloop, that is, main runloop, its role is to keep our OC program running all the Time. In fact, we can think of Runloop as a dead loop, which in this loop is constantly dormant and restarted, thus keeping the program running and handling the various events of the Program. For example: Do{}while (1); iOS has two sets of APIs to use and Access runloop, one is nsrunloop under the foundation, one is the cfrunloopref under the core foundation, (nsrunloop is a cfrunloopref-based oc wrapper). Runloop relationship with threads: each thread has its corresponding runloop, only the runloop of the main thread is turned on by default, and the runloop of the child thread needs to be opened Manually. Runloop is created at the first fetch and destroyed at the end of the Thread. [nsrunloop currentrunloop] [nsrunloop mainrunloop] Cfrunloopgetcurrent () cfrunloopgetmain () runloop related five classes cfrunloopmoderef in Core foundation: represents Runloop's operating mode, Runloop can only run one mode at a time, say either defaultmode, or trackingmode a runloop contains several modes, each mode contains several source\timer\ Observer if you need to switch mode, you can only exit the loop first, and then reassign a mode to enter the purpose of this is to split open different groups of source/timer/observe, so that they do not affect each other. Cfrunloopsourceref: some of the System's click, drag and other events, equivalent to an event source Cfrunlooptimerref: timer-related processing Cfrunloopobserverref: in fact, we can monitor the activities of Runloop , such as listening to it open, whether it will go into hibernation, and so On. These two kinds of runloop are often used in our daily programming: kcfrunloopdefaultmode:app's default mode, usually the main thread is running in this mode UITRACKINGRUNLOOPMODe: interface Tracking mode for ScrollView tracking touch swipe to ensure that the interface is not affected by other modes when sliding in oc, several common Modensdefaultrunloopmode uitrackingrunloopmode: it is important to note that Mode in this model, is only to handle uiscrollview, or inherit from the Uiscrollview object drag and other events, that is, when the Uiscrollview in the rolling, is to enter the uitrackingrunloopmode, By default, the timer is added under nsdefaultrunloopmode, so it is not possible to handle events related to the Timer. (with such a feature, we can optimize the scrolling of UITableView and uicollectionview, we can set the load of the picture under the nsdefaultrunloop, so that when scrolling uitableview, Runloop will be uitrackingrunloopmode, will not load the picture, thereby reducing the phenomenon of lag, making UI interaction Smoother) There is also a nsrunloopcommonmode, it should be noted that it is not the real mode, Just a placeholder if you want to listen for changes in the Runloop state, you have the following code to set the LISTENER:-(VOID) observer{//create Observer cfrunloopobserverref Observer = Cfrunloopobserv Ercreatewithhandler (cfallocatorgetdefault (), kcfrunloopallactivities, YES, 0, ^ (cfrunloopobserverref observer, Cfrunloopactivity activity) {NSLog (@ "supervisor hears runloop status changes%zd", activity); }); Add Listener cfrunloopaddobserver (cfrunloopgetcurrent (), observer, kcfrunloopdefaultmode); Cfrelease (observer);} This is the status Runloop can be monitored:/* Run Loop Observer Activities */typedef cf_options(cfoptionflags, Cfrunloopactivity) {kcfrunloopentry = (1UL << 0),//enter, that is, when Runloop is turned on kcfrunloopbeforetimers = (1UL << 1),//in processing the Before the timer operation kcfrunloopbeforesources = (1UL << 2),//before processing all source sources (click events) kcfrunloopbeforewaiting = (1UL << 5),//will Enter the sleep state kcfrunloopafterwaiting = (1UL << 6),//kcfrunloopexit = (1UL << 7),//back Out Runloop kcfrunloopallactivities = 0x0fffffffu//above All states}; when was the @autoReleasePool released? It is released when its runloop enters hibernation and is created when Runloop is started Again.</pre><p style="margin-left: 60px;"><p style="margin-left: 60px;">Of course, These are theoretical knowledge, in practice we can set ImageView in the Runloop DefaultMode under the display, then when uiscrollview, and controls that inherit from Uiscrollview do not display ImageView when dragged, because Runloop is trackingmode when scrolling.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">You can also open a resident thread so that there is no need to create sub-threads multiple times, resulting in performance loss.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">2, If we use the Sdwebimage framework in development, we will find that when the UITableView scrolling stops, it is the priority to download the image displayed in the cell inside the screen, this effect if you come to realize, how do you do?</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">Development I often use the sdwebimage framework, but did not see its source code, but I did not rely on the sdwebimage framework of the picture download operation, that time is implemented with nsoperation, but also consider the issue of repeated Download.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">Nsoperation can be set to stop (pause), so that the monitor ScrollView scrolling, when the cell leaves the screen, we set it to pause the download status, when it appears on the screen, and then set to open the download status.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">The interviewer asked me if there were any other solutions, (one face--). Then he proposed a good solution, that is, when we set the parallel queue, there is a priority value, we set the image download operation after the priority increment, so that the problem is easily solved.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">(well, I've been using the default priority, and I did not think about it, but the Apple documentation also says that developers are advised to use the default priority, because if the priority level is messy, it could cause the program to crash, but That's not the reason, not knowing.)</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">3, asked under the iOS Factory mode of use scene, in fact, This problem I saw in the "objective-c programming way", but also know it, but that moment is a blank mind, well, then the interviewer and I said, such as the UIButton class method to create, the inside is a black box, We just know it will return a type of what kind of button back, similar, nsvalues and so On. (i have to say lucky, just this problem, in the head of the mobile side of my time, I give such an example)</p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">4, There are three network requests to send, and so on three network requests after sending, to update the ui, how to save time?</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">My first answer, think is directly use Dispatch_group to make good, but the interviewer reminds me, is a network request after sending, wait for the data to return a period of time, so, Dispatch_group is Not.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">then, I think it seems that only a few send, seriously think of the next, in fact, you can set an int attribute, to record whether all returned data successfully, if successful, on + +, and then use KVO to listen to this attribute is Good. (at that time, the answer is that, you should actually use the KVO to listen, you can directly override the property setter METHOD)</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;"></p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">There are other questions, but the impression is not very deep.</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">Mobile-owner Interview:</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">1, at this point, the first side is too, the heart of a sigh of relief. The interviewer came in, first asked me, The iOS program started a series of processes between this, I answered relatively simple, from Main->uiapplicationmain to open a main running Loop->main Runloop began to deal with various source\ observe\timer, from one mode to another mode, and then call Appdelegate inside the application didfinish .... That way, into the Keywindow ...</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;"></p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">2, you know the design pattern of which ideas are said, for example, the application scenario</p></p><p style="margin-left: 90px;"><p style="margin-left: 90px;">Almost kneeling, used to look at the design pattern, that theory too much, can't remember Ah. Then only to say the idea of nine models, barely considered the clearance.</p></p><p style="margin-left: 90px;"><p style="margin-left: 90px;"></p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">3. Write out the sorting algorithm you know</p></p><p style="margin-left: 90px;"><p style="margin-left: 90px;">I was thinking, fortunately not the interviewer to set certain algorithms, I know and can write, bubble, select, fast, merge, write down, sort of clearance.</p></p><p style="margin-left: 90px;"><p style="margin-left: 90px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">Technical Director \ Experience interview</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;">is an algorithm problem, a person on the steps, one can walk one order, walk two orders, go three, then if there is n order, how many kinds of method?</p></p><p style="margin-left: 90px;"><p style="margin-left: 90px;">Recursive problem, According to the previous law, can be easily introduced, f (n) = f (n-1) + f (n-2) +f (n-3), and then in C language to write it Out.</p></p><p style="margin-left: 90px;"><p style="margin-left: 90px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">Then is the personnel side, smoothly get offer.</p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;"></p></p><p style="margin-left: 30px;"><p style="margin-left: 30px;">Ps: My resignation report has been submitted, the company asked me to help him interview iOS staff, I would like to say, those training, write two years of iOS work experience, unexpectedly and I said did not learn c? Not familiar with c? As a computer professional graduate, do the data structure of the problem, 20 only correct 7 road, i go. This line is now how messy, open wages, 10~~15k, and a 15~~25k! Is it true that the ignorant are fearless?</p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;"></p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;"></p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;"></p></p><p style="margin-left: 60px;"><p style="margin-left: 60px;"></p></p><p><p>On an iOS interview</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.