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

Re: stringWithContentsOfURL doesn't work sometimes


  • Subject: Re: stringWithContentsOfURL doesn't work sometimes
  • From: Michael Hanna <email@hidden>
  • Date: Tue, 12 Jul 2005 19:24:27 -0400

Accessing resources with ScreenSavers is problematic sometimes I noticed. For instance borkware.com has some excellent tips on accessing bundle contents:

http://borkware.com/quickies/one?topic=ScreenSavers


This may seem rather unwieldy but what about using CURLHandler to grab the URL? You'd need to add it as a loadable framework at runtime, but it should work fine.


Michael

On 12-Jul-05, at 3:34 PM, Lorenzo wrote:

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


_______________________________________________ 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: Lorenzo <email@hidden>
References: 
 >stringWithContentsOfURL doesn't work sometimes (From: Lorenzo <email@hidden>)

  • Prev by Date: Detecting when an NSStatusItem is present but obscured
  • Next by Date: ot: dvi-d to vga
  • Previous by thread: stringWithContentsOfURL doesn't work sometimes
  • Next by thread: Re: stringWithContentsOfURL doesn't work sometimes
  • Index(es):
    • Date
    • Thread