Wednesday, October 16, 2013

Neighborhoods question about HTTP asynchronous request

Create a single View Application project, and then build a class that implements HTTP request data specifically designed to function
As follows, just write a function to achieve asynchronous call
- (Void) postDataInfo: (NSString *) nsPostVar: (NSString *) nsUrl: (NSString *) nsReferer
{
NSData * postData = [nsPostVar dataUsingEncoding: NSASCIIStringEncoding allowLossyConversion: YES];

NSString * postLength = [NSString stringWithFormat: @ "% d", [postData length]];
NSMutableURLRequest * request = [[[NSMutableURLRequest alloc] init] autorelease];
[Request setURL: [NSURL URLWithString: nsUrl]];

[Request setHTTPMethod: @ "POST"];
[Request setValue: postLength forHTTPHeaderField: @ "Content-Length"];
[Request setValue: nsReferer forHTTPHeaderField: @ "Referer"];
[Request setValue: @ "application / x-www-form-urlencoded" forHTTPHeaderField: @ "Content-Type"];
[Request setHTTPBody: postData];



self.Info = [[NSURLConnection alloc] initWithRequest: request delegate: [AppDelegate App]. viewController]; / / asynchronous processing, commissioned by Lord View receive information


}
Main view of
/ / All data have been received to trigger
- (Void) connectionDidFinishLoading: (NSURLConnection *) aConn
{
NSLog (@ "connectionDidFinishLoading");
}

Also created a new view, specifically to display data
In this viewController, I built a two timer to call postDataInfo
Follows
- (Void) postWonMoney
{
[[AppDelegate App]. ViewController.pwebOperator postDataInfo: Parameter 1: Parameter 2: Parameter 3];

}
/ / / / / / / / / / / / / / / / / View displayed when the implementation of this timer
[NSTimer scheduledTimerWithTimeInterval: (1) target: self selector: @ selector (responseInfoTimer) userInfo: nil repeats: YES];
- (Void) responseInfoTimer {
[Self postWonMoney] ;/ / can be successfully called here, to get the HTTP request data
/ / If here then set a timer, as
[NSTimer scheduledTimerWithTimeInterval: (5) target: self selector: @ selector (responseInfoTimer2) userInfo: nil repeats: YES];
}
- (Void) responseInfoTimer2 {
[Self postWonMoney] ;/ / Here call is unsuccessful, to get the HTTP request data
/ / Program executed self.Info = [[NSURLConnection alloc] initWithRequest: request delegate: [AppDelegate App]. ViewController]; collapsed
}
Is this what the reason, why in the implementation of the first timer there is no problem with it
Reply:
After the collapse of the command-line prompt information given what is?

Reply:
4th Floor reply quote:
after the collapse of the command-line prompt information given what is?

After the collapse of the program transferred here
@ Autoreleasepool {
return UIApplicationMain (argc, argv, nil, NSStringFromClass ([AppDelegate class]));
}
Behind Tip Thread 1: EXC_BREAKPOINT (code = EXC_I386_BPT, subcode = 0x0)
Command line without any prompting
Reply:
Executed
self.Info = [[NSURLConnection alloc] initWithRequest: request delegate: [AppDelegate App]. viewController];
A function of the received
/ / All data have been received to trigger
- (Void) connectionDidFinishLoading: (NSURLConnection *) aConn
{
NSLog (@ "connectionDidFinishLoading");
} Is not running when it was being given, there is not a delegate problems, which then create a TIMER TIMER, then the implementation of the second TIMER function inside to call will be a problem, if only one TIMER, then in the TIMER is Inside the function is executed there is no problem to call
Reply:
4th Floor reply quote:
after the collapse of the command-line prompt information given what is?

Executed
self.Info = [[NSURLConnection alloc] initWithRequest: request delegate: [AppDelegate App]. viewController];
A function of the received
/ / All data have been received to trigger
- (Void) connectionDidFinishLoading: (NSURLConnection *) aConn
{
NSLog (@ "connectionDidFinishLoading");
} Is not running when it was being given, there is not a delegate problems, which then create a TIMER TIMER, then the implementation of the second TIMER function inside to call will be a problem, if only one TIMER, then in the TIMER is Inside the function is executed there is no problem to call
Reply:
Let Ben collapse more fully some of the information given, refer to this: http://stackoverflow.com/questions/5386160/how-to-enable-nszombie-in-xcode

Reply:
May be caused by excessive release.
Need to output more debugging information, refer to:
http://stackoverflow.com/questions/5386160/how-to-enable-nszombie-in-xcode
http://stackoverflow.com/questions/2190227/how-do-i-set-up-nszombieenabled-in-xcode-4
http://blog.csdn.net/linzhiji/article/details/6771998
Reply:
9th Floor reply quote:
may be caused by excessive release.
Need to output more debugging information, refer to:
http://stackoverflow.com/questions/5386160/how-to-enable-nszombie-in-xcode
http://stackoverflow.com/questions/2190227/how-do-i-set-up-nszombieenabled-in-xcode-4
http:/ ......
command line gives the prompt for this
- [CFRunLoopTimer release]: message sent to deallocated instance 0x162ac330

Reply:
Friends with asihttp
Reply:
That problem has been clear. Is released, the object has been released, commonly known as "zombie object." To see that several Timer application and release.
Reply:
self.Info = [[NSURLConnection alloc] initWithRequest: request delegate: [AppDelegate App]. viewController]; / / asynchronous processing, commissioned by Lord View receive information

The front of each assignment, when will a Info release, while in front of the info request is still running, it will go wrong.
Recommend assignment before self.info call it cancel.
Reply:
12th Floor reply quote:
That problem has been clear. Is released, the object has been released, commonly known as "zombie object." To see that several Timer application and release.

Well, right, I follow the prompts predecessors, view CFRunLoopTimer release errors went TIMER problem, it really is the problem here, the second TIMER assignment when we must self. TIMER second object = XXXX , so there is no problem
Seniors can help me look at this display problem, thank you in the evening to pick stickers
http://www.cocoachina.com/bbs/read.php?tid=112855&page=1 # 670884

No comments:

Post a Comment