Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

QR Code Application Advice

Hey Guys,

I am trying to create an iphone application that is similar to RedLaser. I was wondering if someone could give me advice on how you would create the UI when the barcode has been scanned.

Example:

The following image shows what happens when you scan the Nutrigrain barcode. It shows the image, title, and there are even buttons to add to favourites and a list all information is contained within the application and not sent to the safari app:

http://imgur.com/jM63gMJ

I like the way how it is all contained within the application and I would like to do something like this. I'm pretty stuck on understanding how to tell the application what to do once a code has been scanned instead of opening straight to safari like a normal website, and how to code the UI to do this

Thanks!

3 Answers

Patrick Cooney
Patrick Cooney
12,216 Points

There shouldn't be a "default" action. You can tell it what to do once it receives the bar code info. To show it in-app you'd probably have to have a database with an API that could pull information from the DB without needing to go to a webpage. You can then use the returned JSON or (XML) to populate the information of your app in your view controller. This is all assuming when you say you don't want it to open Safari you mean you don't even want to use a webview (which is like safari only on the area of the screen you tell it to occupy.).

Thanks Patrick.

I managed to create a DB in mySQLWorkbench and now i need to look into JSON as you mentioned above. Do you know if there are any tutorials on this?

Patrick Cooney
Patrick Cooney
12,216 Points

Sorry, I was in Puerto Rico last week and early this week and had a pretty spotty internet connection.

Some of the projects on Treehouse utilize JSON. I would go through all the iOS projects here if you haven't already. I'm willing to bet a lot of your questions would be answered. Also the self destructing message app uses a service that does all the database maintenance for you. It might be worth checking out that project and trying to adapt it to your needs.

No Worries.

With your advice, I managed to get this all up and running with JSON and sending it through to the app I designed.

Thanks again!

lol. I dont have a choice plus it's something I want to do for a good cause. I just need to understand how I can create this section of the application.

No Worries.

With your advice, I managed to get this all up and running with JSON and sending it through to the app I designed.

Thanks again!