1. Create a hello WorldProgram
1. Start xcode, file-> new project
Select command line utility on the left and foundation tool on the right.
2. Compile and run
Click build and go or command + R to compile and run the program.
Press done on the keyboard to close the keyboard.
Select textfields in interface builder, find text input Traits in text field attributes, and set return key to done. OK
Definition Method
-(Ibaction) textfielddoneediting :( ID) sender; //
In objective-C, @ property is used to identify attributes (generally instance variables ). Use @ synthesize in the implementation file to identify the declared variables, so that the system can automatically generate the setting and obtaining
When defining classes in objective-C, you can also use public and private variables similar to C ++ to modify member variables, as shown below:
@ Intterface test: nsobject {@ publicint I; Int J; @ protectedfloat m; float N; @ privatedouble X;
Objective-C 2.0Medium,
In the interface file, that is, afterThe suffix name is. HFile, use@ PropertyComeIdentifierAttribute (generallyInstance variables);
InImplementationFileIn the. M file, @ synthesize is used to identify the declared
Objective-CStudy NotesPreprocessingProgramIs the content to be introduced in this article, mainly introducesPreprocessing ProgramStatement usage,Preprocessing ProgramThe statement is marked. Let's take a look at the details.
I. # define
1. More
In objective-C, there is an int data type. Why do we need to use the numeric object nsnumber? This is because many classes (such as nsarray) require the use of objects, whereas int is not an object.Nsnumber is a numeric object. We can use the
Nsstring itself does not allow content and String Length modification. If you want to modify the content, you can use nsmutablestring.
Nsmutablestring is a subclass of nsstring. Therefore, all nsstring methods are applicable to nsmutablestring.
Some of them haven't had time to read it. Put it here first: 1. Treat the object as memory.
The status of each object instance is saved in different memory regions. Therefore, the object creation and deletion actions are equivalent to the allocation
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
I. Preface
For most people who have switched from C ++ or Java to learn object-C (hereinafter referred to as OC), the language OC looks strange and troublesome to use.
OC does not have the same garbage collection mechanism as Java. That is to say,
1. When using xcode to create an objective-C source file, you can check the function of generating a. h file at the same time. xcode is automatically selected here.
2. The code is automatically completed, and the xcode code is automatically
Objective-C: Empty segment Selector
Prelude
Objective-C has a personality. A distinctive feature is that method functions are segmented, that is, function names are not written together, but are split into N segments, which correspond to N
From http://blog.kungfusoft.com/programming/iphone/topic-281.html
When using functions such as nslog and [nsstring stringwithformat:], they all work based on C/C ++-style string formatting.
Originally, C/C ++ has never been used. In iPhone
I have written a similar article before. I want to help my new brother. Pai_^
The objective-C memory management mechanism in the iPhone system is flexible, that is, it can be used like C/C ++, you can also add an autoreleasepool to upgrade it to a
After writing the class declaration and implementation, how can an application call it?
In objective-C, the simple format of calling a method is as follows:
[Instance method]; for example, [person setage: 32]; where person is an instance of the
A collection (nsset) object is a combination of Single-value objects. For example, a set of 1 to 50 numbers.
Operations on collection objects include searching, adding, and deleting members in a set, comparing two sets, and calculating the
The unique data types in objective-C are listed here:
I. String
In objective-C, A String constant is a string sequence enclosed by a pair of @ and a pair of quotation marks. For example, @ "China" and @ "objective-c" are all valid string constants.
In the previous article, I briefly introduced how to implement delegation.In the location framework, the delegate and protocol are used together to implement decoupling and flexibility between objects. Now, based on the previous code, a new protocol
In objc. H, bool is defined:
Typedef signed Char bool; # define Yes (bool) 1 # define no (bool) 0
From the preceding definition, we find that the value of the Boolean variable is YES/NO, or 1/0. Yes or 1 indicates true, and no or 0 indicates false.
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