Ok, I've used - (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait and it's fine one, you've pointed t what was wrong, however I thought that because the method sendLogs was invoqued by an instance that is alive during the whole app lifetime it would be OK. Turns out that NSURLConnections called indirectly by a short time run loop to the main thread doesn't follow up.

Thanks


On 11 avr. 08, at 11:03, Matt Burnett wrote:

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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/matt.w.burnett%40gmail.com

This email sent to [EMAIL PROTECTED]


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to