First, the construction method(i) Call to construct methodComplete creation of an available object: Person *p=[person new];The inner part of the new method calls two methods to accomplish 2 things, 1) Use the Alloc method to allocate storage space
CommentsAlthough it is painful to write, annotations are the key to keeping your code readable. The following rules give you an explanation of when and where you should comment. Remember: Although annotations are important, the best code should be
target-action Model of OBJECTIVE-C release solutionThe target-action pattern is the way the method calls between objects that are very common in OBJC, but OBJC calls the method call a send Message.A bunch of situations can take advantage of this
Description method#import "Person.h"@implementation Person- (void) Setage: (int) Age {_age=Age ;}/** Determines the output result of the instance object **/-(NSString *) Description {return[NSString stringWithFormat:@"age=%i", _age];}/** Determines
Main references in this series:Objective-c Runtime ReferenceObjective-c Runtime Programming GuideMajor documents involved: Objc/message.h,objc/objc-api.h,objc/objc.h,objc/runtime.hCool bar [tekuba.net] Use the Creative commons agreement "attribution-
Basic conceptsProgram of the world and the Human "object" of the world in the mind is no difference, rich two generations inherit the parents, naturally have all the resources parents have, the subclass inherits the parent class also has the parent
Although the grammar of objective-c is so different, so that beginners so uncomfortable, but in fact, it still has a lot of advantages (mainly compared to JAVA).Protocol protocalIn fact, it is the interface, but because OC in the definition of class
In Apple xcode-based objective-C, there are some method naming rules. For example, for property, suppose you have defined the following property:@ InterfaceMyobject @ property (nonatomic, retain) nsstring*Myname;@ EndThen the system will
/*
Used to determine whether the object is the type provided by the parameter (the parameter can be the class of the parent class)Parameter example: [nsobject class];
*/
-
(Bool) iskindofclass :( class) Aclass; /* Used to determine
In iOS, reload can be performed in two ways: 1. The number of different parameters. 2. If the number of parameters remains the same, modify the name of at least one parameter. This is a strange overload method. Even if the return type is modified,
It is easy to extend an existing class in C #, for example:
Public static class utils {public static void printtoconsole (this string strsrc) {console. writeline (strsrc );}} In this way, a printtoconsole method is added to the string class. The
As mentioned in the previous article, member variables are declared in a large pair of arc, while attributes are first declared by @ property and then synthesized by @ synthesize. Attribute is a new mechanism of OC language. In actual use, there are
I have been dealing with object-oriented objects for some time. At that time, I learned OOP through C ++, and later I came into contact with PHP and Java. Every OOP language is more or less different in Object-Oriented aspects. Now I am learning the
Block is equivalent to the function pointer in C or C ++, and is equivalent to the delegate in. Net or Java.
// Block Declaration
Double (^ blockname) (double, double) =
^ Double (double firstparam, double secondparam ){
Return firstparam *
Object-Oriented Programming (1)
Process-oriented programming
C language is a process-oriented programming language. Let's take a piece of program code to gain a deeper understanding of process-oriented.
Draw a set chart:
//// Main. M // OC //
Preface
In Java, we can access the public member variables of an object through "Object Name. member variable name", which is called "Point Syntax ". For example:
1. define a common member variable Age in row 2nd of the student class.
1 public class
For beginners, objective-C has a lot of confusing statements, but they are actually very elegant.
What programmers write most are functions and functions written by themselves or written by others. This article describes the elegance of objective-C
I. Introduction 1. C Language
C language is a process-oriented language. OC adds the smallest object-oriented syntax based on C language. Why is it the smallest object-oriented syntax? Because OC removes some complex object-oriented syntaxes, and
When I read a piece of code today, I found that when NSString is instantiated, sometimes the initWithFormat method is used, and sometimes the stringWithFormat method is used. How should I choose?
Differences:
1. initWithFormat is the instance method.
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