Re: NSURLConnection doesn't post
Re: NSURLConnection doesn't post
- Subject: Re: NSURLConnection doesn't post
- From: Matt Burnett <email@hidden>
- Date: Fri, 11 Apr 2008 04:03:29 -0500
Are you calling test: or sendLogs in a thread which doesnt have a
active run loop, or a thread that will soon terminate? Either one will
cause issues for NSURLConnections.
On Apr 10, 2008, at 7:27 AM, Micha Fuhrmann wrote:
Hi there,
I'm running into a problem with NSURLConnection and I can't solve
it, any help greatly appreciated.
in my main (Shared Instance) class i have the following code to post
crash logs:
- (IBAction)test:(id)sender{
[self sendLogs];
}
- (void)sendLogs
{
NSMutableString* logsPath = [[NSMutableString alloc]init];
[logsPath appendString:[[NSBundle mainBundle]bundlePath]];
[logsPath appendString:@"/Contents/logs/"];
NSDate *currentDate = [NSDate date];
NSString * theTime = [[currentDate dateWithCalendarFormat:@"%Y-%m-
%d %H:%M:%S" timeZone:[NSTimeZone localTimeZone]]description];
NSFileManager *manager = [NSFileManager defaultManager];
bool doesTheLogsFolderExist = [manager fileExistsAtPath:logsPath];
NSMutableString * theDate = [[NSMutableString alloc]init];
[theDate appendString:@"error_"];
[theDate appendString:[[currentDate dateWithCalendarFormat:@"%d_%m_
%Y" timeZone:[NSTimeZone localTimeZone]]description]];
[theDate appendString:@".log"];
[logsPath appendString:theDate];
NSString* theXmlAsString = [NSString
stringWithContentsOfFile:logsPath encoding:NSUTF8StringEncoding
error:NULL];
NSXMLDocument* theLogsXmlData = [[NSXMLDocument alloc]
initWithXMLString:theXmlAsString options:NSXMLDocumentTidyHTML
error:nil];
NSString* content = [@"xmlData=" stringByAppendingString:
[theLogsXmlData XMLString]];
NSURL* url = [NSURL URLWithString:@"http://www.theappstore.net/support/logs_reports.php
"];
NSMutableURLRequest* urlRequest = [[NSMutableURLRequest alloc]
initWithURL:url];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setHTTPBody:[content
dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *connectionResponse = [[NSURLConnection alloc]
initWithRequest:urlRequest delegate:self];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:
(NSData *)data
{
NSString* thhhe = [[NSString alloc]initWithData:data
encoding:NSASCIIStringEncoding];
}
Now if I place a button on my interface and call test everything is
fine, the post is submitted and the delegate method is called.
Suffice I call the test method from another class and nothing gets
posted (break points show me the sendLogs method is indeed called),
the didReceiveData method is not called either. I've looked into
adding the NSURLConnection into an array so it wouldn't be scraped,
created a separate send class just for the post etc. to no avail, I
really don't know what I'm doing wrong.
Any help very much appreciated.
Micha
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden