Common methods of NSNumber
Why use a numeric object NSNumber when you have a data type for int in objective-c? This is because many classes, such as Nsarray, require the use of objects, and int is not an object.NSNumber is a digital object we can
Introspection (introspection) is a powerful feature of object-oriented languages and environments, and objective-c and cocoa are particularly good at this aspect. Introspection is the ability of an object to reveal its detailed information as a
The Protocol (PROTOCOL) in Objective-c is similar to the commonly used interface, the method defined in the Protocol (Protocols), implemented in the class.
@protocol Myfirstprotocol
-(void) Myfirstprotocolmethod;
@end
In the iphone OS, Protocol (
is about to release Swift 4, oneself is also learning swift, behind the IOS programming estimated also fast is the world of swift, but I still in this hold a book that says OC is gnawing, strange only blame oneself before too lazy, according to
Read the Horky classmate's "mixed use objective-c,c++ and objective-c++" blog, I also have some ideas to record, easy to learn in the future1.objective-c/C + +/C depth blending is not a good choice, prone to error, and poorly maintained, and when
Objective-c Objects for memory management1. Value types: such as int, float, struct and other basic data types.
Value types are placed in the stack, occupying a contiguous memory space in memory, followed by the advanced post-out principle,
The primary role of a category is to extend functionality, which means adding new methods and not encapsulating attributes.If you want to add an attribute, you can use the associated object helper to implement#import "Test.h" @interface Test (Other)
1, in OC, [] is used to adjust the method,. is also looking for methods, mainly to find the Get method,-> is used to find variables. _p is a direct access to instance variables.2. In OC, the instance variable is a protection class and cannot be
The Objective-c method is described by two data types: One is the selection sub (SEL), which describes the name of the method, and the other is the implementation (IMP), which describes the code that is actually executed when the method is called
1, the use of random numbers 1), arc4random () more precise do not need to generate the seed immediatelyHow to use:The code for obtaining an integer between 0 and X-1 by Arc4random () is as follows:int value = Arc4random ()% x;The code to get an
Categories Category1, overviewAdd new methods to existing classes, and the objective-c term for these new methods is "category".2, UsageA, Declaration category@interface NSString (numberconvenience)-(number *)
KVC (key-value-coding?) 1, overviewA method that sends or obtains a value as a string to an instance variable or property of an object.2, usageA, take the value@property (readwrite,copy) nsstring * name; Car.h@synthesize NAME;//CAR.MNow, I want to
Block type
Block is a data type that is widely used in iOS development and is highly recommended by Apple, which functions like a function pointer in C.^ is a unique symbol of block.The implementation code for the block is included in the {}.In
runtime abbreviation. is the system at the time of the operation of some mechanism, the most important is the message mechanism. For the C language, the function's call will decide which function to call at compile time (see here for the C-language
1. IntroductionThe knowledge of block is described in the previous article [New learn] explaining the block knowledge of objective-c. In this chapter we will take a practical example to briefly describe how block replaces proxies.2. The original
Like NSString, Nsarray, Nsdictionary is immutable, and its corresponding variable type is nsmutabledictionary. Its usage is as follows:#import@interfaceStudent:nsobject@property (nonatomic, retain) nsstring*name;+ (ID) Studentwithname: (NSString *)
In OC, methods are divided into class methods and instance methods.+ is a class method, which can be called directly with the class name.-For instance methods, you must use an instance of the class to invoke.@interface People:nsobject-(void) eat;+
First, the objects in OC are represented by pointers, and the invocation of the method is based on the message mechanism, = =The nature of the comparison is the address pointed to by the pointer and then the difference between isequal and
1. Define and use block1 #import "ViewController.h"2 3 @interfaceViewcontroller ()4 5 @end6 7 @implementationViewcontroller8 9- (void) Viewdidload {Ten [Super Viewdidload]; One A //define block no return value, no parameter -
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