Objetive-C learning _ Block learning notes, objetive-c_block
Block: an anonymous function with an automatic variable (local variable.
Block: used to save a piece of code and can be called when appropriate.
Block essence: struct, which contains a function pointer
Block application scenarios: animation, multithreading, set traversal, and network request callback
Block format: ^ return value type parameter li
instancevi. Relationship between OC instance object class object meta-Object(1) Each object is an instance of a class.(2) Each object has a pointer to the object named Isa, which points to its class.(3) Each class describes the characteristics of a series of its instances, including a list of member variables, a list of member functions, and so on.(4) Each object can accept the message, and the message list that the object can receive is saved in the class it corresponds to. Copyright NOTICE: T
Some time ago, during sokcet communication under Objetive-C, when the C ++ program was used as the server, everything was normal. When Java was used as the server, neither party received the data, after reading some documents, sort out the notes
1. Press enter and line feed at the end of the message.
When Objetive-C sends data, add "\ r \ n" to the end"
_ Datatosend = [nsdata datawithbytes: "This is a
atomic operation. If multipleWhen a thread calls the setter at the same time, one thread does not appear before the entire setter statement is executed, and the otherWhen a thread starts executing a setter, it is the same as the method ends with a lock.Nonatomic: The atomicity of Setter/getter is not guaranteed, and data may be problematic in multithreaded situations.nonatomic, non-atomic access, non-synchronous, multi-threaded concurrent access improves performance. First release the originalv
A delegate is a class.
namespace ConsoleApplication1{ internal delegate void MyDelegate(int val); class Program { static void Main(string[] args) { } }}
Use reflector to view the delegate il code:○ Delegate is indeed a class○ Delegate constru
Delegate (1): Delegate and method, delegate Method
1. Use delegate to take methods as method parameters
Let's take a look at a small example:
Namespace delegate Example 2 {/******* delegate Example 1 * Note: This program main
A delegate in C # is similar to a function pointer in C or C + +. Using delegates enables programmers to encapsulate method references within a delegate object. You can then pass the delegate object to code that can invoke the referenced method without having to know at compile time which method will be invoked. Unlike function pointers in C or C + +, delegates a
Delegate is a type of secure encapsulation method, which is similar to function pointers in C and C ++. Unlike function pointers in C, delegation is object-oriented, type-safe, and insurance. The delegate type is defined by the delegate name. The following example declares a delegate named Del, which can encapsulate a
Commissionedis to put a method as a parameter into the declaration (Deletgate) delegate. To another method, or execute the delegate directly.1 classDelegates2 {3 Public Delegate voidMyDelegate (stringmsg);4 Static voidMain (string[] args)5 {6MyDelegate myd =NewMyDelegate (father. Buytoys);7MyD"BBB");8 Console.read ();9 }Te
Delegate is a type of secure encapsulation method, which is similar to function pointers in C and C ++. Unlike function pointers in C, delegation is object-oriented, type-safe, and insurance. The delegate type is defined by the delegate name. The following example declaresDelCan encapsulate a method that uses a string as a parameter and returns a void.
public
Use the '-' operator to remove a delegate from a delegate chain1 classHelloWorld2 {3 //Defining delegate Types4 Delegate voidDelegationchain ();5 Static voidMain (string[] args)6 {7 //using a static method to delegate an instance8Delegatio
I've been optimizing a WinForm form application to show how to lower the module's low coupling through "delegates" and "events."
But before that, we have to understand what a low coupling is.
The simple thing is that two modules, if a class in a module, you need to instantiate a class in another module, and then call the method so that the two modules are tied to a chariot, and if a module disappears suddenly, an error is made, and all we have to do is add the method in a module to a
Today, there is a netizen, ask:
There are several small text files in the specified directory, and you now need to use multithreading for reading.
A file can be a thread or set of 10 threads in a way.
Append all the read text to the specified edit box in the window, and only one edit box is written in this, in this case, in the order of wrapping.
I wrote the following solution in the form of a delegate:
Using System;Using System.Collections.Gener
[. NET Basics]-delegate, event, thread (1),. net delegate1. Delegation is the list of pointers for storing methods, that is, the container for loading methods.
A. Create A winform project [01 Delegate]. Add the dg_SayHi.cs delegate class to the Project for storage methods.
Namespace _ 01 delegate {// define
Before reading the following knowledge, I already think you already have C # Foundation, including simple delegate knowledge; Code is developed using VS2008, but will be written in the. Net Framework 2.0 (C Sharp)
What is. NET asynchronous mechanism?
Before we explain this topic, let's look at the synchronized program, which is our usual Hello World program.
Code 1:
1 class Program
2 {
3 static void Main (string[] args)
4 {
5//view current thread
C # commissioned the basic series was originally published in February 2011 in my Sina blog, now it will be like this blog.
Multi-Channel delegation
Class Program {public delegate void Saythingtos (string s);
void SayHello (String s) {Console.WriteLine ("Hello {0}", s);
} void Saygoodbye (String s) {Console.WriteLine ("Goodbye {0}", s);
} static void Main (string[] args) {//mode one Saythingtos say1, Say2, Say3, Say4;
Delegate and event (1), delegate eventI personally think that the most important essence of c # is its delegation.
To be honest, it is now the era of c #5.0, and c #6 will soon come out. As a c #1 delegate, it has long been encapsulated by more advanced tools such as generic delegation and lambda expressions. Basically, few people declare a
9. Delegate, event, Lambda, and delegate event lambda
There must be a problem with delegation.The first question is what is delegated? Look at the description in. net: On the. net platform, the delegate type is used to define and callback in the corresponding application. (Callback? A technique used to process two physical bidirectional communication in the memor
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.