开发者

how to return image and int with php script to an iphone

开发者 https://www.devze.com 2023-03-09 02:56 出处:网络
i wrote an iphone app which uses NSMutableURLRequest and NSURLConnection to call .php script on a server which gives an image back with the commands file_get_contents and echo.

i wrote an iphone app which uses NSMutableURLRequest and NSURLConnection to call .php script on a server which gives an image back with the commands file_get_contents and echo. but i would like to retur开发者_如何学编程n beside the image an int-value. how can i realise this the most elegant way?


Server-side: prepend the int to the raw image data that your PHP script outputs (eg., with PHP's . operator)

Client-side: split the received NSData on the iPhone after the NSURLConnection finished loading the request. You can use [NSData subdataWithRange:] for that. Check out the answers to this question for more info and an example.

Look out for data encoding differences (I suggest using UTF8 encoding throughout your infrastructure).

There are probably many ways of doing what you want, some of which will be better than this method, but it should work!

0

精彩评论

暂无评论...
验证码 换一张
取 消