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 return beside the image an int-value. how can i realise this the most elegant way?
Asked
Active
Viewed 160 times
1 Answers
0
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!

Community
- 1
- 1

Wilbo Baggins
- 2,701
- 3
- 26
- 39
-
thank you! i did prepend it to the image data but thought it would be the wrong way to reach the goal... all right. think i will make it now! – Maxi Buschmann May 30 '11 at 22:26