ASIHTTPRequest 在同步模式下吞噬了我的 NSOperation 变量

发布于 2024-08-18 18:42:38 字数 848 浏览 3 评论 0原文

嘿,我已经和这个问题作斗争有一段时间了。也许我在有关多线程的知识中缺少一些东西,但这就是发生的事情。当我创建 nsoperation 队列时,分配的任何变量都会在“[request startSynchronous];”之后被清除。行代码。这就是我要说的:

@implementation imageLoadOperation
@synthesize object;

-(id)initWithObject:(NSMutableArray *)receivedObject
{
 ...
 object = receivedObject;
 ...
}
- (void)main {
 ...
//send request
 printf("retreiving photo info from server\n");

 NSURL *url = [NSURL URLWithString:[siteUrl stringByAppendingString:@"/connect.php"]];
 ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
 [request setPostValue:@"lookAtPhoto" forKey:@"purpose"];
 [request setRequestCookies: [ASIHTTPRequest sessionCookies]];

该对象仍然存在于此处

[请求开始同步];

然后物体就消失在这里了!

我确信这与原则理解上的差距有关,但我已经重新安排代码好几天了,但没有成功。

...

Hey I have been battling with this problem for a while now. Perhaps there is something I am missing in knowledge about multi threading but here is what happens. When I create an nsoperation queue any variables that are allocated become cleared after the "[request startSynchronous];" line of code. Here is what I'm talking about:

@implementation imageLoadOperation
@synthesize object;

-(id)initWithObject:(NSMutableArray *)receivedObject
{
 ...
 object = receivedObject;
 ...
}
- (void)main {
 ...
//send request
 printf("retreiving photo info from server\n");

 NSURL *url = [NSURL URLWithString:[siteUrl stringByAppendingString:@"/connect.php"]];
 ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
 [request setPostValue:@"lookAtPhoto" forKey:@"purpose"];
 [request setRequestCookies: [ASIHTTPRequest sessionCookies]];

The object still exists here

[request startSynchronous];

Then the object disappears here!

I'm sure this has something to do with a gap in principle understanding but I have been rearranging the code for days now to no success.

...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晒暮凉 2024-08-25 18:42:38

天啊我简直不敢相信。我没有以正确的方式设置对象来触发属性保留。 >自体客体

awww gosh I can't believe it. I wasn't setting the object in the correct way to trigger the property retain. > self.object

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文