0

I'm making a iOS game which will pick a random clue(text) and image (clue and image come in a set, 1 row) from the clue repository in the database. I have a web service with webMethods and functions that allow me to pull the database row out. (tested for clue) I've been searching on Google for articles on how to import image to iOS from db but to no avail.

how to import image from DB by web service (build using c#)? Can anyone please guide me in the right direction? I would like it to be stored in mutableArray so that after the player are done playing, the clue and image will be wipe off the temp array. (i don't want to put the image in the app as that will make the app very large and that user are able to upload their own clues and image, so live feed from database is the ideal method.

Right now I'm stuck on the web service side on importing the image over. I'm currently using List to store the clue, but have no idea on what to use to store image. I am thinking of using ArrayList which store object, but have no idea how to convert it to image at the iOS side. And as I mentioned above, I can't seem to find any tutorial or example that import image to iOS app via web service. (or am I using the wrong search term)

Will be helpful if any1 can help me out, or give alternate solution which enable live update of image and clues.

EDIT - I found ImageList() and List. which one should I be using now? Also found out to make image file is just -> image testfile;

EDIT2 - problem I'm facing
-dealing with image file (image? imagelist?
-when drawing datarow from DB in  webservice, how do i deal with the image file. (guessing ImageList or List<image> (after some luck on research)
-assuming 2nd point works fine, i should be able to solve the client side
(sorry, noobie at webservice, )

.

what I have
-webservice that draw datarow from database for clue(string) (tested and working fine with my function)
-iOS client side with RESTful architecture

.

what I need
-webservice that draw datarow from database for picture(image (format not so important yet)) (code should be similar to drawing clue, only which function to store it in. (using List<string> for clues)
3
  • 2
    First of all you should use WCF and not use ASMX web services. That's a legacy technology that shouldn't be used for new development. Aug 10, 2012 at 3:54
  • It is still a bit unclear to me what is actually the part you have problems with. The List and ImageList - do you want to use them on the client side, I suppose? You're also mentioning that you have problems importing the image (server side). I think some things are being mixed here. Could you please rephrase the question and provide more information? It would also be helpful if you could point out exactly what you have and what is causing you problems (in points). That will make answering easier. Aug 10, 2012 at 16:55
  • List<image> and ImageList() are c# function. but I don't know which 1 i should use. Something similar to List<string> and ArrayList where ArrayList is outdated. Aug 11, 2012 at 3:49

2 Answers 2

2

Sounds like you might be getting a bit ahead of yourself. Try solving just one problem at a time; you'll make much more progress.

First, do you know how to download an image to your iOS application? Try downloading a very simple publicly available image like a Google doodle: https://www.google.com/logos/2012/gymnastics-2012-hp.jpg. Whatever IOS application toolkit you're using should have a walkthrough for how to download an image and present it via HTTP.

Second, do you know how to host an image file on your web server? Try downloading a random JPG or PNG image yourself and hosting it on your server as a static file. Then point your IOS application at that static file and download it just like you did with the Google doodle.

If both of those steps work, you can then begin to host dynamic images on your server. Create a page (if you're using ASP.NET) or a controller path (if you're using MVC) and have your C# code use Response.TransmitFile to upload an image to the clickstream. Again, download that image to your IOS application to verify it worked.

Finally, modify your server application to take a parameter - either by a querystring (example: myhost.com/mypage.aspx?image_id=1) or by an MVC path (example: myhost.com/images/1). Use that ID number to retrieve the image information from your database. Then transmit the image to the client. If all goes well, you should then be able to retrieve this image in your IOS app.

I hope this helps you get closer to your project!

1
  • you're right... solving them one at a time will make it less error prone. Thanks for the advice and tips, will start by making webMethod to upload image to db. Aug 11, 2012 at 6:06
1

I have no experience programming on iOS, but I think that the easiest way is to prepare RESTful api for that. With the REST guidelines in mind, what you end up with is a webservice that defines a resource, and your client needs only to request a particular file (I assume that client somehow knows what the id/name of the image is). This has one big advantage - it is very easy to develop (on any platform) - server side.

When it comes to client side: 1. Use WebRequest object to create a http get request 2. Wait for the data to be downloaded (you may use background worker or just another thread, so that your app is not blocked) 3. When request is complete and you get the response object - read what was sent. It is going to be binary image. 4. Use the binary data (image) and display it in your app.

A sample of how to use WebRequest object is provided by me in different SO thread: https://stackoverflow.com/a/11891240/165751

Note: I assume you know how to retrieve the image from the DB (or any kind of store actually) on your server side so that your webservices can read it and return it as a webresponse.

There are plenty of possibilities when it comes to server side technology, but if you want to stay with .Net technology stack - I suggest to have a look at WCF REST Service Template 40(CS) - I've been using it in the past (and my service was returning images as well :) and I was very happy with it.

3
  • sorry, i think i have to rephrase the question and the details already. im currently using webservice. i got the function and method to pull strings, but not sure on which approach to use to pull image. I cant find any function to touch on image Aug 10, 2012 at 9:14
  • I am not sure what strings are you talking about. I was trying to suggest using WCF rest service so that client can request an image. If you have web service up and running already - what does it do exactly? Is client app able to download image? Or is it only returning an URI to the image (that needs to be downloaded later)? Where do you want to pull image from? From DB (but on server side)? Or from server (using web-service) on the client side? Aug 10, 2012 at 16:58
  • I guess using client side to call webservice which will pull the image from the DB. from image pulled, then i will load it into the array in the client. Guess what I really want is the basic of how to deal with image. Which I found ListImage and List<image> (c# function on webservice) Aug 11, 2012 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.