Re: stringWithContentsOfURL doesn't work sometimes
Re: stringWithContentsOfURL doesn't work sometimes
- Subject: Re: stringWithContentsOfURL doesn't work sometimes
- From: Lorenzo <email@hidden>
- Date: Wed, 13 Jul 2005 12:48:42 +0200
Thank you but I already know how to get resource files from within a
screensaver using NSBundle. My question was different.
I meant that the API stringWithContentsOfURL cannot get the string and my
screensaver freezes just there. Nothing to do with resources.
And I would like to avoid (just in this software) other 3rd parts code like
CURLHandler.
The Apple code "PingHost" freezes the screensaver too. So it's not a problem
related to stringWithContentsOfURL. It seems to be related to the fact that
the screensaver is installed within
(Home)/Library/Screen Savers
and it occurrs only on some machines. Why? Proxy? FireWall? What?
The problem never occurrs when the screensaver is installed within
/Library/Screen Savers
Any idea?
Best Regards
--
Lorenzo
email: email@hidden
> From: Michael Hanna <email@hidden>
> Date: Tue, 12 Jul 2005 19:24:27 -0400
> To: Lorenzo <email@hidden>
> Cc: email@hidden
> Subject: Re: stringWithContentsOfURL doesn't work sometimes
>
> 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