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.
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
1. Category)
The classification in object-C is a compilation method that allows us to expand a class by adding a method (but new instance variables cannot be added through category ), and we do not needCodeThis is similar to defining attributes
@ Interface => start to define a class.
@ End => end
@ Implementation => class implementation
@ End => end
# Import => reference header files
@ Property => Objective-C 2.0 syntax, defining an attribute
ID
ID
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, the process for defining a singleton class is as follows:
1. Define a static class object. The initial value is nil.
2. In the factory method (generally named "sharedinstance" or "sharedmanager"), use allocwithzone only if
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,
1. Objective-C calls the js method. You only need to call the method that comes with uiwebview.
[Webview stringbyevaluatingjavascriptfromstring: [nsstring stringwithformat: @ "gethtmlstring ('% @')", htmlstr];
2. When JS calls the objective-C
IOSDevelopmentObjective-CAndJavascript InteractionThe operation is the content to be introduced in this article. It mainly explains the usage of stringbyevaluatingjavascriptfromstring. It is very powerful and easy to use, through this, we can easily
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
Http://www.davidhamrick.com/2012/02/12/Adding-Properties-to-an-Objective-C-Category.html
Let's say you have a category that needs to store some information. Unfortunately you can't add an instance variable, but you can add something called an
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
In: argument is an input argument only and won't be referenced later
Out: argument is an output argument only, used to return a value by reference
Inout: argument is both an input and output argument
Const: The (pointer) argument is constant
In addition to category, objective-C has an associative extension mechanism.
Category is common and serves to extend some new methods to existing classes.
So associative is something that category cannot do, and attributes can be extended.
Official
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.
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:
After using objective-C language for iOS development for a period of time, I found my language base was relatively weak and began to make up for my shortcomings. I found that after using a language, I can look back at many of its principles to find
First, introduce the framework audiotool.
-(ID) initwithpath :( nsstring *) path { uint32 size, maxpacketsize; char * cookie; int I; If (gthereisanactivetrack) { nslog (@ "*** warning *** gbmusictrack only plays one track at a time! You must
1. Category (categories are also called categories. Add methods for classes without source code (System Classes and others' classes)
1) Role
Extends others' classes and can be used as an alternative to subclasses.
Put the code of the same class
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.