Category is a great concept. You can use a category to add new methods to any class, including those you do notSource code.This is very convenient.To add a new method to a class, we usually create a subclass.However, subclass is sometimes
1. category can be used to add new methods for existing classes.
2. categories can be managed and implemented. Multiple methods of different categories can be put into different. M files. For example, nswindow has many categories, such as
From: http://blog.csdn.net/pjk1129/article/details/6458644
This article introduces the new properties of objective-C language, where category allows you to add your own methods to existing classes, the Protocol is a special Inheritance Method in
# Import Int Main ( Int Argc, Char * Argv []) { If (Argc = 1 ) {Nslog ( @" You need to provide a file name " ); Return 1 ;} File * File = fopen (argv [ 1 ], " R " ); Char Words [ 100 ]; While (Fgets (words, 100 , File) {words
From cocoa programming for Mac OS X 3rd
Mark the token order with a formatted string
When a text is converted from one language to another, Words and Phrases change accordingly due to word order changes. For example, the statement"Ted wants a
This articleArticleThis article introduces the comparison between objective-C and the underlying content, mainly explaining the differences between initialize and init methods. In this article, we can not only understand what objective-C did during
Nil can only be applied in the ID type, that is, the pointer to the object in Java and C ++. Null is used as a non-object pointer.
See the following example:
-(Void)Observevalueforkeypath Nsstring *)Keypath ofobject ID)Object
Share the code for implementing the singleton mode in objective-C.
It seems that the design pattern is rarely mentioned in MAC development... At least we haven't seen any design patterns implemented with objective-c...
Code
Code
There are two methods to create an object in OC:
[Class Name New]
[[Class name alloc] int]
Allocation and initialization are two separate operations: To do nsobject class method alloc allocates a memory area for the object and clears it. The
You can use dictionaries to store data, which improves the search speed.
The following describes how to create a dictionary.
Nsdictionary * DIC = [nsdictionary dictionarywithobjectsandkeys:
@ "Wtq", @ "name1 ",
@ "WTM", @ "name2 ",
@ "WTP", @
Syntax used for quick enumeration:For (type newvariable in expression) {statements}OrType existingitem;For (existingitem in expression) {statements}
Objects cannot be changed during enumeration.
Use the following three classes for quick
Class Definition:
Although the compiler is not mandatory, the type of interface declaration and implementationCodeIt is best to put them in two different files for developers who use these classes to view them easily.
The implemented file
The content of this series corresponds to the content described in the official objective-C language, which is divided into the following parts:
Object, type, message
Define a class
Allocate and initialize memory for objects
Search for files
Next we will use a program to combine the knowledge learned above, such as nsstring, nsmutablearray, nsenumerator, and nsfilemanager to operate the file system, such as creating directories, deleting files, moving files, or
1. Dynamic Allocation
Dynamic Allocation is handled by two functions: malloc and free. Use a parameter to call malloc to request memory. This function specifies the number of bytes required. Malloc returns a pointer to the number of bytes in the
Keyword in OC, @ property and @ synthesize pair.
Syntax:
@ Property (parameter 1, parameter 2) variable type variable name
@ Synthesize variable name
Function:
Let the compiler automatically compile a method declaration with the same name as the
Path: NSPathUtilities. h
NSPathUtilities. h contains NSString functions and classification extensions, which allow you to operate on the path name.
The following is an example:
# Import # import # import # import # import int main
Link to the original article: a large number of objective-c developers have emerged in the past few years at http://pilky.me/view/21. Some are transferred from dynamic languages, such as Ruby or Python, and some are transferred from strong languages,
This blog introduces the length of the basic data type, how to use the basic data type in the array of Oc, and the conversion of other data types.
To demonstrate the basic data type example, we create an iPhone project class as an example.
1. Create
The code block is essentially similar to other variables. The difference is that the data stored in the code block is a function body. Using code blocks, you can pass in the number of parameters and get the return value just like calling other
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