• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSURLConnection doesn't post
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSURLConnection doesn't post
      • From: Micha Fuhrmann <email@hidden>
References: 
 >NSURLConnection doesn't post (From: Micha Fuhrmann <email@hidden>)

  • Prev by Date: Re: NSURLConnection doesn't post
  • Next by Date: Re: Singletons on Leopard with GC
  • Previous by thread: Re: NSURLConnection doesn't post
  • Next by thread: Re: NSURLConnection doesn't post
  • Index(es):
    • Date
    • Thread