0

我试图通过其他两个对象类传递我当前的 NSObject 类的引用,这样我就可以访问我调用的原始 NSObject 类的当前初始化。

我将尽可能简单地概述我这样做的原因。我有 3 个 NSObject 类和一个 appDelegate。

  1. 应用委托
  2. 远程站点
  3. 引擎请求
  4. 引擎响应

这是应用程序的逻辑流程

Appdelegate.m
calls RemoteSites method "GetRemoteSites" this method reutrns a BOOL for confirmation

RemoteSites.m
-(BOOL)GetRemoteSites {
// calls EngineRequests method like so
EngineRequests *engineRequests = [[EngineRequests alloc] init];
[engineRequests GetRemoteSites:self];

//..
}

EngineRequests.m

- (void)GetRemoteSites:(NSObject *)myObjectClass {
 // get everything ready to send off request
}

send off request then return recived data + NSObject refrence to EngineReasponse

EngineReasponse.m
- (void)GetRemoteSites:(NSData *)receivedData Object:(NSObject *)requestingClass
{
// pass requestingClass to a NSObject var that will later be used to pass the data back to the original class that started the request
 requestingClassObject = requestingClass
}

//..
[requestingClassObject GetRemoteSitesNow:reducedDataPacket]; // GetremoteSitesNow is a method inside RemoteSites class, however using requestingClassObject I cannot see any of the classMethods my class has in it
//..

这就是我要完成的整个流程,重点是尝试让 -(BOOL)GetRemoteSites 返回 Yes 给 AppDelegate。

总之,我的问题是这样的。为什么我不能从EngineReasponse 访问RemoteSites 方法,我认为我已经正确传递了类对象引用,但由于某种原因我无法访问这些方法。

任何解决我的问题的帮助将不胜感激。

4

1 回答 1

1
EngineRequests.m

- (void)GetRemoteSites:(id)remoteSites {
 // create your class object here or globally.  

RemoteSites *remotesite = (RemoteSites*)remoteSites

}

EngineReasponse.m

- (void)GetRemoteSites:(NSData *)receivedData Object:(id)requestingClass
{

RemoteSites *requestingClassObject = (RemoteSites*)requestingClass
}


//
[requestingClassObject GetRemoteSitesNow:reducedDataPacket]; 
//

抱歉打错了。希望它会有所帮助。

于 2013-07-17T04:05:11.293 回答