I now put before doing c + + code to ios platform, OC layer ViewController call C + + interface to the thread to complete some operations, after the operation is completed, I need a callback notification OC layer, now I'm using a delegate way to callback OC layer ViewController the method was
For example, this
C + + layer
Class CplusplusClass
{
id delegateUpdate;
void func ()
{
ThreadDosomething ();
[DelegateUpdate updateFunc];
}
}
CplusplusClass * g_gloableCpp;
OC layer
@ Protocol delegateUpdate
- (Void) updateFunc;
@ End
Then set g_gloableCpp-> in ViewController in delegateUpdate = self;
And achieve updateFunc Interface
Such OC layer and C + + layer to achieve a two-way exchange.
I said before, I was a novice in the beginner, many are very faint.
Today saw two articles, said to be too MCV in IOS mode,
I have reprinted the article to my space
1. IOS in the MVC http://blog.csdn.net/yeyunxiaofeng/article/details/15378035
2. IOS How to choose delegate, notification, KVO http://blog.csdn.net/yeyunxiaofeng/article/details/15378023
According to the figure
Generally use between Model and Controller KVO and notification to the completion callback
I do not want to tangle down my C + + code belongs Model layer or Controller, Controller might like some of it, anyway, I was finished with the delegate and
OC layer controller callback
I'm here to compare want to know is if I use C + + layer KVO or notification to the above features, is able to complete, is there any need to pay attention.
Also, I looked at NSURLConnectionDelegate and NSURLConnection
Both also communicate through the completion callback delegate, then theoretically it should belong to controller NSURLConnection do?
I may now compare the three entangled in a division of MCV, experts hope to give a few examples, to help me doubts it. Thank you.
Reply:
If I use the C + + layer KVO or notification to the above functions. Did not understand the meaning of this sentence
MVC it is mainly M and C, V in iOS more casual, if done with nib file interface, then it still has a View layer, if the interface is a strong line and directly in the code inside, and Controller stir together.
Model class and function is to achieve, Controller is responsible for the Model displayed in View.
Incidentally, the figure is inside the open class at Stanford, to see if there is any doubt the video like slightly
Reply:
I mean, C + + layer, get some work done in the thread, the callback to notify OC layer, using KVO or notification to complete
No comments:
Post a Comment