• 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
stringWithContentsOfURL doesn't work sometimes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stringWithContentsOfURL doesn't work sometimes


  • Subject: stringWithContentsOfURL doesn't work sometimes
  • From: Lorenzo <email@hidden>
  • Date: Tue, 12 Jul 2005 21:34:56 +0200

Hi,
I made a screensaver.
In order to verify if the user is connected to internet I try to get a
stringWithContentsOfURL from a text file posted on my web site. I append a
random number after the URL link to avoid cached results. I get two
problems.


1) if the user is not connected I don't get any error in the variable error.
   Anyway the string I should get remains empty so I understand the user is
   not connected. Not too bad.
2) when the screensaver is installed in /Library/Screen Savers/
   it properly gets the string with stringWithContentsOfURL all the time.
   But when the screensaver is installed in (Home)/Library/Screen Savers/
   it freezes just when it calls stringWithContentsOfURL. This occurrs on
   some machines only. I presume they have a FireWall. Anyway, the FireWall
   should not involve the result of stringWithContentsOfURL.
   Don't you think so?

Do you know how to fix/workaround the problem?
I include here my code.

----------------------
    link = @"http://www.mydomain.com/connection_text.txt?";;
    randomIntString = [[NSNumber numberWithLong:rand()] stringValue];
    fileURLPath = [link stringByAppendingString:randomIntString];

    getText = @"";
    url = [NSURL URLWithString:fileURLPath];
    if(url){
       err = [NSError errorWithDomain:NSURLErrorDomain code:0 userInfo:nil];
       getText = [NSString stringWithContentsOfURL:url
                encoding:NSISOLatin1StringEncoding error:&err];
    }
    // the text file contains the string "YES".

    connection = ([getText length] != 0);
----------------------


Best Regards
--
Lorenzo
email: email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: stringWithContentsOfURL doesn't work sometimes
      • From: Michael Hanna <email@hidden>
  • Prev by Date: [[myObj retain] autorelease]
  • Next by Date: Re: Predicate Problems
  • Previous by thread: Re: [[myObj retain] autorelease]
  • Next by thread: Re: stringWithContentsOfURL doesn't work sometimes
  • Index(es):
    • Date
    • Thread