First define a human parent class
Definition:
/// Human. h // OOP // created by Jimmy. yang on 11-2-9. // copy 2011 _ mycompanyname __. all rights reserved. // # import @ interface human: nsobject {bool sex;} + (void) tostring;-(void) showsex; @
If the lifecycle of an object is obvious, it is easy to know when to use a new object and when it is no longer needed. In this case, you can use manual retain and release to determine whether a person is born or dead. However, sometimes it is not
1. for Chinese characters and some non-URL strings, use stringbyaddingpercentescapesusingencoding:
Nsstring * escapedurlstring = [unescapedstring stringbyaddingpercentescapesusingencoding: nsasciistringencoding];
2. The above method does not work
Uiwebview is one of the most commonly used sdks for iOS. It has a stringbyevaluatingjavascriptfromstring method that can embed Javascript into the page. Through this method, we can interact with webpage elements in uiwebview in IOS.
I 've been learning objective-C Programming for a while, and now it's over. Next, let's start programming in IOS. Previously, to avoid forgetting, I decided to spend a few days summing up what I learned before, saving my time for forgetting.
We know that in objective-C, using @ property with @ synthesize enables the compiler to automatically implement the getter/setter method, which is convenient to use and can be directly used.Object. Attribute.
Nsstring
*
Name;Nsuinteger age; @
In Java, we often use Singleton mode. These design modes are also commonly used in iOS development. Recently, we are also considering using Singleton mode in iOS development.
In objective-C. the M file defines static variables to indicate global
OBJ-CThis quality is "improvedC Language", We all know that C language does not have garbage collection (GC) mechanism (Note: Although obj-c2.0 later added GC function, but not on the iPhone, so for iOS platformProgramThis is almost useless), so
This article is hard to understand. Because this is a big question, and I just want to summarize it for myself, I didn't want to write a long tutorial. Think about it. Write a memorandum to make it concise.
According to the development guidelines
So far, I have seen two methods of serialization implemented by OC: nskeyedarchiver and nspropertylistserialization.
In both serialization methods, nsdata is the target of serialization. The difference between the two methods is that
Obtain the current date: nsdate * Date = [nsdate date]; // However, In this method, the UTC event is obtained.
Nsdate * Date = [nscalendardate date]; // obtain the local time.
Get the date of yesterday:
Nsdate * Yesterday = [[nscalendardate
Objective-C provides a good type judgment and reflection mechanism. The foundation of OC isC LanguageAll objects are represented by pointers. The actual type information of a pointer may be blurred during transmission. You can use type queries to
// 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
A section on reading a book todayCodeWhen nsstring is instantiated, sometimes the initwithformat method is used, and sometimes the stringwithformat method is used. What should I choose?
Differences:
1,Initwithformat is the instance method.
It
The previous article demonstrated how to use the traditional "process-oriented programming method" to draw "rectangles", "Circles", and "ovans ", this article describes how to use the OOP method to implement it:
Because the two enumeration
Basic Data Type 1. intOutput Format: % I, % d, % o % x, 2. FloatOutput Format: % F, % E, % G 3. DoubleOutput Format: % F, % E, % G 4. Char Output Format character: % C Qualifier: 1. LongLong INT: % LiLong double: % lfTo form a long
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.
Document directory
Nsnumber Value assignment:
Nsarray assignment and access:
Nsdictionary assignment and access:
New syntax features of objective-C 1. Improvement of enumeration types
Previously, I declared that the enumeration method is
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