IOS interview questions: Basic concepts < Continuation of OC titles >

Source: Internet
Author: User

First, how to determine the name of a method method
Delete minus, add, delete return value, delete parameter type, delete parameter, the rest is the method name

Seconds, ID, can use Assign,copy,retain, according to need to use

Thirdly, when did the Autorelease release?
Release when encountering Autoreleasepool (able to put several of the same variables in a few different dominant)

The method of the protocol, by default, is @required

What are the features of the dictionary collection?


A dictionary is a saved element in the form of a key-value pair
can only store objects, cannot store basic data types

Six, how to define a class?
The interface portion of the class includes instance variables, properties, and methods
The ability to put declarations and implementations in. h files
A pair of files (Person.h person.m) can define multiple classes
The analogy is more abstract, the object is more detailed

VII, what is a category?


Class can be added to a class without source code.
The method in the class is the same as the method level in the original class.

To rewrite the parent method to a subclass with inheritance

Ninth, what is an object?
Object is an instance of a class, such as President Barack Obama

Tenth, the properties of the property,

For details, please click on the link below

Properties of the OC property



11th, do not tune yourself within the set method, and you will fall into a dead loop


12th, the difference between a mutable string and an immutable string
nsmutablestring * str = [[nsmutablestring alloc]initwithformat:@ "123"];
NSLog (@ "str =%p", str);
[Str appendformat:@ "456"];
NSLog (@ "str =%p", str);
The address printed above two times is the same

13th, a dictionary key is unique, so the dictionary has a function of the weight, print the dictionary, the left is key, the right is value

14th, you cannot use an instance variable in a class method

15th, Dealloc note (with the system to invoke the initiative itself)
Open Arc can't write [Super Dealloc] Method
OC cannot be overloaded (the method name is the same as the number of parameters) and can only be rewritten,

16th, the Singleton method is only for the purpose of obtaining a unique instance, usually without a reference in the method
A singleton is equivalent to a global variable and cannot be released.
For example, user login, write user information in Singleton

17th, the initial function is to assign the initial value to the variable

18th, @package

The @package (frame level) scope is between private and public, and can be directly interviewed by the variable name only in the same frame.


19th, queue advanced first out, stack advanced after

20th, dynamic binding
NSString * Testobject = [[NSData Alloc]init]
Compile-time is nsstring type (not measured)

NSData type at execution time (test)

Here is a rough, detailed OC dynamic characteristics please click on the following link

In-depth objective-c dynamic characteristics


21st, block modifies external variables with __block

22nd, why use assign instead of retain when delegate or protocol apply for attributes?

The Declaration of the Agreement, with the Assign attribute, avoids the circular reference, please click below for more information.

Why use assign instead of retain when delegate or protocol apply for attributes?

Frequently used traversal operations in iOS


The purpose of the traversal is to get an object in the collection or to run an operation, so that the method that satisfies the condition can be an alternative:
Classic for Loop
for in
Makeobjectsperformselector
KVC Set operator
Enumerateobjectsusingblock
enumerateobjectswithoptions (nsenumerationconcurrent)
dispatch_apply

24th, the property is the method is not a variable category inside is the method does not add the variable

25th, see the traversal of the constructor, to think of Autoreleasepool, sometimes the convenience of the constructor is often a memory leak error


26th, the protocol is a list of methods that are shared by multiple classes, and the methods listed in the protocol do not have corresponding implementations, and others implement
The property declaration of the Protocol uses the Assign attribute, which prevents the memory from being freed because the object and other proxy objects are prevented from referencing each other


27th, categories, extensions, agreements, succession differences
Category: The category can not be learned, do not change the original code in the case of adding a new method, only can join, can not delete the original method, but cannot add the instance variable

Extension: Extension can add instance variables and methods at the same time, and the method must be implemented, can be regarded as a private class

Protocol: A protocol is a list of methods that are shared by multiple classes, and the methods listed in the protocol do not have a corresponding implementation

Inheritance: Not only can add instance variables and methods, but also can rewrite the method of the original class

28th, when Autorelease no Autoreleasepool
Since the object that the convenience constructor produces is not autoreleasepool, it cannot be released, so when the loop value is too large, the resulting object will be more and more and the used object cannot free up the memory consumption more and more. Severely affects performance so to use Atutoreleasepool in a For loop, this frees memory to avoid memory leaks.

Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

IOS interview questions: Basic concepts < Continuation of OC titles >

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.