我刚刚接触ios,mvc和xcode,oc都是初学,很多东西都很晕。
我现在把以前做得c++代码移植到ios平台,OC层ViewController调用C++的接口,线程内完成一些操作,操作完成以后,我需要回调通知OC层,现在我是使用delegate的方式来回调OC层ViewController中得方法
比如这样
C++层
Class CplusplusClass
{
id delegateUpdate;
void func()
{
ThreadDosomething();
[delegateUpdate updateFunc];
}
}
CplusplusClass *g_gloableCpp;
OC层
@protocol delegateUpdate <NSObject>
-(void)updateFunc;
@end
然后在ViewController中设置g_gloableCpp->delegateUpdate=self;
并且实现updateFunc接口
这样OC层和C++层就实现了双向互通。
前面说过了,我是初学中得初学,很多都很晕。
今天看了两个文章,讲得是IOS中得MCV模式,
文章我都转载到我的空间 了
1. iOS里的MVC http://blog.youkuaiyun.com/yeyunxiaofeng/article/details/15378035
2. iOS 如何选择delegate、notification、KVO http://blog.youkuaiyun.com/yeyunxiaofeng/article/details/15378023
根据上图
Model和Controller之间一般采用KVO和notification来完成回调
我现在倒不想纠结我的C++层代码是属于Model还是Controller,可能更像Controller一些吧,反正我是用delegate完成了和
OC层的controller的回调
我在这里比较想知道的是,如果我在C++层使用KVO或者notification来完成上述的功能,是否能够完成,是否有什么需要注意。
我现在把以前做得c++代码移植到ios平台,OC层ViewController调用C++的接口,线程内完成一些操作,操作完成以后,我需要回调通知OC层,现在我是使用delegate的方式来回调OC层ViewController中得方法
比如这样
C++层
Class CplusplusClass
{
id delegateUpdate;
void func()
{
ThreadDosomething();
[delegateUpdate updateFunc];
}
}
CplusplusClass *g_gloableCpp;
OC层
@protocol delegateUpdate <NSObject>
-(void)updateFunc;
@end
然后在ViewController中设置g_gloableCpp->delegateUpdate=self;
并且实现updateFunc接口
这样OC层和C++层就实现了双向互通。
前面说过了,我是初学中得初学,很多都很晕。
今天看了两个文章,讲得是IOS中得MCV模式,
文章我都转载到我的空间 了
1. iOS里的MVC http://blog.youkuaiyun.com/yeyunxiaofeng/article/details/15378035
2. iOS 如何选择delegate、notification、KVO http://blog.youkuaiyun.com/yeyunxiaofeng/article/details/15378023

根据上图
Model和Controller之间一般采用KVO和notification来完成回调
我现在倒不想纠结我的C++层代码是属于Model还是Controller,可能更像Controller一些吧,反正我是用delegate完成了和
OC层的controller的回调
我在这里比较想知道的是,如果我在C++层使用KVO或者notification来完成上述的功能,是否能够完成,是否有什么需要注意。