OC point syntax and variable scopes
One, point grammar
(a) Understanding point grammar
Declare a person class:
Copy Code code as follows:
#import
@interface Person:nsobject{int _age;//defaults to @protected}
-(void)
IOS9 has added a lot of new features (What ' New in IOS 9.0-apple Developer), and the search feature is interesting to me. In a nutshell, there are three different ways to implement local and server two searches.
Try it yourself. The second is to
1, @class: declaration is a classWhen we actually use the class, import the class using import
2, the following code will be an error, because import can not reference each other, this is just a @class declaration class can#import "B.h"@interface A:
Nsarray is an immutable group in the Foundation framework, let's implement these methods:
#import int main (int argc, const char * argv[]) {@autoreleasepool {//oc array can be Storing objects of different types; the array of OC can only store
We know that in C, using sizeof () to calculate the number of bytes occupied in the memory, after referencing string.h, use strlen () to calculate the length of the string (not including).
In Object-c, the "Length" method can return the length of a
OC and C + +, Java and other object-oriented languages have a lot of similarities, but in many ways is also different. If you use an object-oriented language, it is easy to understand the paradigms and templates used by the OC language. But the use
First, description methodThe description method includes class methods and object methods. (Included in the NSObject Class)(i) Basic knowledge-description (Object method)When you use NSLog and @% to output an object, the object's description method
after iOS6.0 and OS X10.8, Apple introduced a set of informal protocols (informal protocol) that are directly bound to the OBJECTIVE-C syntax. Once you have implemented this method, you can use the array subscript to access the attribute elements
In essence, the communication interaction between OC and JS is to send the message, that is, the function call, iOS7 after the official release of the JavaScriptCore framework is very convenient for us to call each other. In the past, we could only
Blocks Block Code SnippetBlock encapsulates a piece of code that can be executed at any time. It is an extension of the function in C, which is actually implemented in C, so it is valid in all languages based on C, including Objective-c, C + +, and
Delegate modeTipThe delegate object should not be retainThe class that implements the delegate pattern should:
Has an instance variable named Delegate_ to refer to the delegate.
Therefore, accessor methods should be named Delegate and
1. There are often some variables in the class that require set and get operations, and OC provides convenient attribute @property to replace the set and get methods, which reduces the frequent and simple duplication of code. The following
The Objective-c control statements have the following three categories:Branching statements: If-else,switchLooping statements: While,do-while,forJump statement related to program transfer: Break,continue,goto.
Branch statementsBranching
The classification in objective-c allows us to augment it by adding a method to a class (but we cannot add new instance variables through category), and we do not need to access the code in the class.The protocol in OBJECTIVE-C is a ubiquitous
1. data type.Int % OFloat % FCouble %Char % C
2. instance variable scope commands:@ Protected the instance variable can be directly accessed by the class and any method defined in the subclass (default ).@ Private instance variables can be
Objective-C is the preferred language developed on Apple Mac OS X, and it is so brilliant. A few days ago, the author Dave dribin interviewed the father of objective-C, Brad Cox, to learn about how this great man views his programming path.
We all
For iPhone development, we use instruments when detecting all of them during execution, but sometimes we can eliminate these in the cradle. Static analysise.
You can run build and analyze directly for the build check. You can also check that the
% @ Object % d, % I integer % u unsigned integer % F floating point/double character % x, % x binary integer % O octal integer % zu size_t % P pointer % E floating point/double character (Scientific Computing) % G floating point/double character % s
Use of Public, protected, and private in objective-C
Similar to C ++, the use of public, protected, and private exists in objective-C, but the forms are different. Here is a brief summary.1. @ public, @ protected, @ privateI personally
Today, I saw an article in the garden titled "Objective-C 2.0 with Cocoa Foundation --- 5, Class type, Selector and function pointer, you can't help but add comments to the code so that you can view it later. My personal experience: the "Class type
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