ASIHTTPRequest 在同步模式下吞噬了我的 NSOperation 变量
嘿,我已经和这个问题作斗争有一段时间了。也许我在有关多线程的知识中缺少一些东西,但这就是发生的事情。当我创建 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
天啊我简直不敢相信。我没有以正确的方式设置对象来触发属性保留。 >自体客体
awww gosh I can't believe it. I wasn't setting the object in the correct way to trigger the property retain. > self.object