Hi,
I have a simple app for iOS(pure objc) that I use the following code:
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://fabiosistemas.com.br/a=user&b=extra&c=100"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
receivedData = [[NSMutableData data] retain] ;
} else {
// error message - Inform the user that the connection failed.
}
And I have the following methods that I use to manage the connection
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
// it can be called multiple times, for example in the case of a
// redirect, so each time we reset the data.
// receivedData is declared as a method instance elsewhere
NSLog(@"zzz");
[receivedData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
// append the new data to the receivedData
// receivedData is declared as a method instance elsewhere
NSLog(@"xxxx");
[receivedData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
//NSLog(@"Connection failed! Error - %@ %@",
NSLog(@"yyy");
}
- (void) connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]);
}
But I want to use this within cocos2d-x, how I can do that, I already rename the cpp files to mm files, but I don’t know how I can use the management(I don’t know the correct name) methods