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.
Common nsfilemanager operations
-(Bool) contentsatpath: path // read data from the file specified by a path-(bool) createfileatpath: path contents :( nsdata *) data attributes: ATTR // write data-(bool) removefileatpath: path handler: Handler //
Objective-C uses nsstring to operate strings. nsstring is called a non-modifiable string because the content and length of a string cannot be modified when you create a string using nsstring.
1. Create a string
Nsstring * STR = @ "I Am a
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.
For arrays, dictionaries, and collections, objective-C provides an enumeration method to access each element. There are two methods:
Method 1:
Nsarray * array = ...; member * member; int COUNT = [array count]; for (INT I = 0; I
Method 2:
Nsarray is a static array that does not modify or add elements to the array. Therefore, nsarray alone is not enough. Nsmutablearray came into being to meet our needs.
Summary of common nsmutablearray Methods
Array
Create
In objective-C, the cocatouch framework further encapsulates the native socket, that is, stream.
Add cfnetwork framework
Initialize socket
Cfreadstreamref readstream; cfwritestreamref writestream; cfstreamcreatepairwithsockettohost (null,
In objective-C, the call method is calledSend message
The notification object performs an operation. Syntax:[Shape draw]
I. Class Declaration (Interface ):
@ Interface testcoop: nsobject {Int Imonth;Int iyear;Int iday;}
-(Void) setyear: (INT)
The lock is the basis of the thread programming synchronization tool. The lock makes it easy to protect a large part of the code so that you can ensure the correctness of the Code. 1 use POSIX mutex
POSIX mutex lock is easy to use in many
Example ~ To implement
Interaction between JavaScript and objc
How does one implement JavaScript to call an interface inside objc?
I implemented it in this way.
For example, an entry
JS
Function testclick (CMD, parameter1, parameter2)
{
Alert (1
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
The role of the Protocol is similar to the multi-inheritance of abstract base classes in C ++. Similar to the interface concept in Java.The Protocol is a list of multiple class sharing methods,Methods listed in the Protocol are not implemented in
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.
Nsmutablestring common methods for modifying strings
+ (ID) stringwithcapacity: Size
Create a string with the size
-(ID) initwithcapacity: Size
Initializes a string with the size
-(Void) setstring:
Http://www.codeios.com/thread-26-1-1.html
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 of unnecessary work. after
KVC
[Object setvalue: avalue forkey: akey]; // assign a value to the akey variable of the object
Avalue = [object valueforkey: akey]; // obtain the value of the akey variable of the object
[Object setvalue: avalue forkeypath: akeypath]; // set
Three Characteristics of object-oriented encapsulation, inheritance, and Polymorphism
Encapsulation: Hiding internal implementations and stabilizing external interfaces.
Encapsulation is to define the class definition property definition
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