• 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: php call from Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: php call from Cocoa


  • Subject: Re: php call from Cocoa
  • From: Lorenzo <email@hidden>
  • Date: Wed, 21 Sep 2005 15:45:17 +0200

Thanks, with NSASCIIStringEncoding it works all the time.
In my php script I simply return strings like "File Found" so I suppose that
NSASCIIStringEncoding should always work. If not, please let me know.

With "immediate" I mean

    int result = [self CallPHP];
    if(result == 0) return YES;
    else return NO;

within the same method. Instead NSURLConnection starts a download in a
thread, so I can get a result only with
    connectionDidFinishLoading:(NSURLConnection*)connection
therefore I have to split my code in 2 pieces like

- (void)check
{
    [self startNSConnectionWithSender:self];
}

- (void)setResult:(BOOL)flag
{
    result = flag;
}

and in the NSConnection subclass

- (void)connectionDidFinishLoading:(NSURLConnection*)connection
{
    if([receivedData length] > 0){
        int result = [self dataToResult];
        [sender setResult:result == 0];
    }
}

Best Regards
--
Lorenzo
email: email@hidden

> From: j o a r <email@hidden>
> Date: Wed, 21 Sep 2005 14:28:32 +0200
> To: Lorenzo <email@hidden>
> Cc: email@hidden
> Subject: Re: php call from Cocoa
>
>
> On 21 sep 2005, at 14.20, Lorenzo wrote:
>
>> I have to call a php script on my web server
>>     http://www.dom.com/get.hph
>> it returns a string. Actually I call
>>
>>     phpPath = [NSURL URLWithString:@"http://www.dom.com/get.hph";];
>>     response = [NSString stringWithContentsOfURL:phpPath
>>                 encoding:NSUTF8StringEncoding error:&error];
>>
>> It works sometimes. Many times it returns nil (but the error code
>> is still
>> zero). We have already spoken here that instead of using
>> stringWithContentsOfURL it is better to use NSURLConnection, but
>> before I
>> implement it, I would like to know whether there is a better way.
>
> Could it be that it returns *nil* because the string is not in UTF8
> format? Try with Latin1 and see how that works. You would get better
> feedback using NSURLConnection.
>
>> Also NSURLConnection is asynchronous while I need immediate feedback.
>
> What do you mean with "immediate"? Making it synchronous probably
> doesn't make it any faster.
>
> j o a r
>
>
>

 _______________________________________________
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: php call from Cocoa
      • From: j o a r <email@hidden>
References: 
 >Re: php call from Cocoa (From: j o a r <email@hidden>)

  • Prev by Date: Re: Mysterious warning (initialization from distinct Objective-C type)
  • Next by Date: Re: Using an IB-built view multiple times
  • Previous by thread: Re: php call from Cocoa
  • Next by thread: Re: php call from Cocoa
  • Index(es):
    • Date
    • Thread