Get started with iOS development, start with the most basic environment, and today we'll look at how to fully match the OBJECT-C environment.My Linux system is ubuntu14.04. Given that there is no money to buy a MacBook, the black Apple Computer card
OC Method and file compilationFirst, OC method(i) Object methods(1) Object method with-opening as-(void) xx;(2) Object methods can only be called by object(3) The member variables of the current object can be accessed in the object method(4) Call
Code blocks are essentially similar to other variables. The difference is that the code block stores the data as a function body. With code blocks, you can pass in the number of parameters as you would call other standard functions, and get the
When writing object-oriented programs, we often want to add some new behavior to existing classes. Sometimes, we can create subclasses of this class. However, if we use the Toolset or the class library, we cannot handle the new subclass. At this
A preface to the reflection mechanism of objective-c from the perspective of JsonmodelIn the era of mobile interconnection, JSON is almost ubiquitous as a data transmission format. As an iOS developer, how do I get a string of JSON strings to handle?
objective-c (Initialize)Creating Objects (programming language OBJECTIVE-C 2.0)1. class objects and instantiationAfter the definition of the class is complete, the compiler automatically generates a unique class object in memory, and the instance
Code blocks are essentially similar to other variables. The difference is that the code block stores the data as a function body. With code blocks, you can pass in the number of arguments as you would call other standard functions, and get the
In Objective-c, we can use the numeric data types in C, int, float, long, and so on. They are all basic data types, not objects. That is, it is not possible to send messages to them. Then, there are times when you need to use these values as objects.
A copy of an object can be created using the copy or nutablecopy method. The original object is not affected when the copy is modified.
Copy : Must be implemented first
Nscopying Protocol ,
Creating an immutable copy (Such as nsstring, nsarray,
Introduction:
In the previous article, we talked about KVC. In this article, we learned KVO. The full name is: key value observing. the literal translation is: key value-based observer.
So what is its use? KVO is mainly used for view interaction.
@ Indicates the "objective-c" flag, proving that you are using the objective-C Language
Objective-C language keyword, @ property and @ synthesize pair.
Function:Let the compiler automatically write a method declaration with the same name as the
Objective-C underlying data structure
Objective-C underlying data structure
Class Data StructureClass (pointer)
Typedef struct objc_class * class;/* this is the data structure generated by the compiler for each class. This structure defines a class.
// Implement carparts
// Implement carparts # import @ interface tire: nsobject @ end @ implementation tire-(nsstring *) Description {return (@ "I Am a tire. I last a while. ");} @ end @ Interface Engine: nsobject @ end @ implementation
Three features: encapsulation, inheritance, and Polymorphism
Encapsulation:Encapsulation of member variables in order to filter invalid attribute values, we need to provide a method to set the age attribute values for the outside world.
Set
Master haomeng is devoted to his contribution and respects the author's Labor achievements. Do not repost them.
If the article is helpful to you, you are welcome to donate to the author, support haomeng master, the amount of donation is free,
Describes common objective-c Functions and constant variables.Arithmetic functions
Arithmetic functions]
Function Name
Description
Int rand ()
Random Number Generation.(Example)Srand (Time (NiL); // initial
# Import @ interface classvirable: nsobject {nsinteger year; // protect the tree} @ property int age; // setage is available without @ synthesize in the implementation file: and age method-(void) set :( nsinteger) I; @ end
#import
Struct
Nsange:
Used to indicate the range
Create
Nsange R1 = {2, 4}
Nsange r2 = {. Location = 2,. Length = 4}
Nsange R3 = nsmakerange (2, 4)
Search for the range of a string in Str
Nsstring * STR = @ "I love OC ";
Nsange range = [STR
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