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; //
Class is the core of objective-C, and objective-CProgramAll are performed around classes. The objective-C program consists of at least three parts:
1. Class interface: defines the class data and methods, but does not include the implementation of
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 //
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;
Category is one of the most common functions in objective-C.
Category can add methods for existing classes without adding a subclass.
The standard syntax format of the category interface is as follows:
# Import "class name. H" @ Interface
Http://www.davidhamrick.com/2012/05/28/Adding-Properties-to-an-Objective-C-Category-Revisted.html
In my last post I wrote about adding properties to a categoryIn objective-C. I have ended up using this feature quite a bit recently so I wrote a
Http://www.cocoachina.com/macdev/objc/2011/0124/2602.html
In the class implementation of objective-C, we often see the two keywords "self" and "super". Taking the previous OOP language experience as an example, C ++ assumes that self is equivalent
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
Using oC to call JS is simple. The system provides the stringbyevaluatingjavascriptfromstring method.
[Webview stringbyevaluatingjavascriptfromstring: @ "document. Location. href"]; [webview stringbyevaluatingjavascriptfromstring: @ "jsmethod ()
Common nsfilehandle operations
+ (Nsfilehandle *) filehandleforreadingatpath: path // open a file for the read operation + (nsfilehandle *) filehandleforwritingatpath: path // open a file for the write operation + (nsfilehandle *)
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.
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, when a class is used to another class and the referenced pointer needs to be created in the Class header file,
I. # import and @ Class
The following code is used:
A. H file
#import "B.h"@interface A : NSObject { B *b;}@end
For
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
1. nsarray is a static array. The content and length of the created array cannot be modified.
Instance:
// Use arraywithobjects to initialize an unchangeable array object. // Separate initialized values with commas (,) and end with nil. Nsarray6 *
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
Delegation is often used in iOS development framework cocoa touch. It means that a class object requires the delegate object to perform some of its operations. The delegated mechanism is actually a design mode, through which the coupling between
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.
Category is one of the most commonly used functions in objective-C. Category can add methods for existing classes without adding a subclass. In addition, we can add methods for a class without knowing its internal implementation. If we want to add a
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.