By classification, you can add new methods to existing classes without the need for source code. This is a bit like the Extension Method in C.
In this case, an example is provided to convert a string into a camper type and remove spaces.
After learning objective-C for a week, I read the classic "Learn objective-C on the Mac". Learn and remember, and send Study Notes to your blog for reference anytime, anywhere.
Write iPhoneProgramOr the Mac OS X software mainly uses xcode on the
Guidance: translated from:10 IOS libraries to make your life easier
Because the ios sdk is relatively low-level, developers have to do more physical work. Fortunately, there are many third-party class libraries that can be used to simplify a lot
1. for Chinese characters and some non-URL strings, use stringbyaddingpercentescapesusingencoding:
Nsstring * escapedurlstring = [unescapedstring stringbyaddingpercentescapesusingencoding: nsasciistringencoding];
2. The above method does not work
A New Keyword @ dynamic is added to objective-C 2.0 to define dynamic attributes. Compared with @ synthesis, dynamic attributes are not automatically generated by the compiler, setter, or getter, but are dynamically added at runtime.
Generally,
The following describes the runtime behavior of the OC class. This includes method replacement during running, message forwarding, and dynamic attributes. These are still very useful for the love of Aspect-Oriented Programming AOP. Of course, there
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
In the previous article, allCodeThey are all placed in the same file main. H. This is obviously not a good method. When the code is too large, it will be too big. You can split it:
1,Put all enumeration and structure definitions in one file
Objects in obj-C include nsarray, nsdictionary, nsstring, nsnumber, nsdate, nsdata, and their variable versions (nsmutablearray, nsmutabledictionary... in this way, you can easily serialize your data in a certain format (such as XML format) and save
// Main. M // helloworld // created by Jimmy. yang on 11-1-24. // copy 2011 _ mycompanyname __. all rights reserved. # import // define the ry type enumeration typedef Enum {kcircle, krectangle, koblatesshperoid} shapetype; // define the ry color
Since multiple forms of source files can be written in objective-C, different file extensions can be used to differentiate them. Table 2-1 shows the file extension description:
Table 2-1 Description of file extensions
File Extension
If you want to learn objective-C, please pay attention to it. We recommend some learning materials for you and hope it will be useful to you !!!
Getting startedArticle:
Learn objective-C is very simpleLearn objective-C
PropertyProbablyObjcUnique element inProgramming Mechanism, used to quickly generate class data membersGetAndSetMethod. This articleAbout mePropertySome usage experience.
1) Retain, copy, and assign:
Retain is used to generate the reference
Address: http://amattn.com/2011/10/15/the_disposition_of_objective-c.html
After ten years of objc programming, I will discuss some comments on objc here.
Verbose)
This is the most obvious objc feature. Objc programming always uses extremely
In the obj-C world, there is no such official saying as "interface" or "generic. However, there are two concepts close to OBJ-C: "Informal protocol" and "formal protocol )". Although the keyword of the informal protocol in obj-C is also interface,
Recently, a small application was developed to read Sina Weibo. The newly published Weibo posts on Weibo do not tell you when to release it, but tell you the time relative to the current time a few seconds ago, a few minutes ago, or a few hours ago.
4. Cocoa memory management rules1) when you create an object using the new, alloc, and copy methods, the reserved counter value of this object is 1. when you no longer use this object, you are responsible for sending a release or autorelease message
7. comprehensive example: Searching for filesProgram function: Find a local file (.jpg) in the main directory and output the list of found files.Nsfilemanager provides operations on the file system, such as creating directories, deleting files,
Chinese scanned version + English ebook + source code
This resource is compressed by betterzip on a Mac, with three volumes uploaded to csdn.Use 7zip in Windows to decompress the package.
Because the resources are too large (the Chinese version
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.