Definitions of classes and methodsGeneral classes are inherited NSObject, a new class when the parent class select NSObject, OC only single inheritance, not many inheritance.
Below with a simple OC project to explain (need to configure the Xcode
1. First prepare the document containing all the provinces and cities, and drag the document into the Xcode we built.
2. Then create a new path nsstring *path = @ ""; Then drag the provincial urban documents to the @ "";
3. Before sorting, we
Dictionaries can also be variable. The common method for changing dictionaries is as follows:
#import
int main (int argc, const char * argv[]) {
@autoreleasepool {
Nsmutabledictionary *dict = [[Nsmutabledictionary alloc] init];
Bought this "learn Objective-c on Mac", a start to buy looks very thin, 250 pages, after reading, found that the language has a lot of common place, the new features are from C + + and Java similar to come over, is changed a name, feel after seeing
Let's just say this: the difference between the message structure and the function callis also a method of invoking an object,Objective-cObject *obj = [Object new];[obj Performwith:parameter1 and:parameter2];C++Object *obj = new Object;Obj->perform (
First, OC Introduction1.OC is an object-oriented programming, the main decomposition of the problem composed of objects, coordinate the object to contact and communication to solve the problem.2.C language is a process-oriented idea, which analyzes
The first thing to note is:" Auto Reference Count " (Automatic Reference counting, ARC, see 30th) is not " exceptionally safe " by default (Exception safe). Specifically, this means that if an exception is thrown, the object that should have been
OC is an enhanced C feature, so it is basically consistent with C on variables and basic data types.In OC, variable naming has the following rules:Consists of letters, numbers, underscores, and $ symbolsMust start with a letter, underscore, $
1: What is @property?In Objective-c, @property is the syntax for declaring attributes, which makes it quick and easy to create getter/setter methods for instance variables.2: The nature of @property?@property = Ivar + setter + getter, is actually
OC is an extension of the C language, and almost all applications on OS X or iOS platforms are developed in that language.
You can use the Toolkit cocoa (OS X System) and Cocoa Touch (for iOS systems) to develop fully functional objective-c
I. Grammatical specifications1. Class: Abstract description of a thing, such as the abstraction of humans, dogs and cats into animal classesTwo files in OC to describe a class1>. H: declaration file for a class declaring member variables and methods,
Objective-cClass, Object, methodThe actual variable is an instance of the class.The actions that an instance can perform are called methods.[Classorinstance Method];Defining classes@interface Classname:superclassDefine method as interface@endClass
Singleton mode iOS development may be used in one of the most commonly used patterns. But because OC language features itself, want to write a correct singleton mode is more cumbersome, iOS singleton mode design ideas.Please refer to this article
First, the use of autoresizing (understand)Only the parent control can be referenced1, to achieve the screen switching, can not be the control of the frame capillary, the need for screen adaptation2. You need to refer to the parent controlUse Auto
Understanding Method Swizzling is a good opportunity to learn the runtime mechanism. Not much to do in this, only translated by Mattt Thompson published in Nshipster's method swizzling article.Method Swizzling is a technique that changes the actual
The protocol in OC (PROTOCOL) is similar to the interface in. NET (Interface), which is simply a list of a series of methods that can be implemented by any class. The difference is that in. NET, if a class implements an interface, it must implement
Dynamic languageOC is a dynamic language, and its method, the type of object, is to be determined only when it is run. So this makes OC a powerful mechanism for associating objects.Associating objectsThe so-called associative object, in fact, is
? The instance variable is available in degrees.
Visibility of
features
Public (Common)
Instance variables can be manipulated outside and inside the class
Protected (protected, default)
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