Category Archives: cocoa – PHP

How To Make A Simple RSS Reader iPhone App Tutorial

When making iOS apps that have to download data off of the Internet, you run into a lot of challenges. You have to:

  • Write code to retrieve the data off of the network
  • Write code to parse and interpret the data
  • Write code to run the above in the background, so your app remains responsive
  • Update your UI in an animated fashion as data arrives so the user can see what’s going on

That’s a lot of different concepts to put together. So in this tutorial, you’ll get hands-on experience doing exactly that by making a simple RSS reader app!

This tutorial was specially requested and sponsored by William Mottl, a kind supporter of this blog. Thank you William!

Read more

How To Create A Socket Based iPhone App and Server

This is a post by iOS Tutorial Team member Cesare Rocchi, a UX designer and developer specializing in web and mobile applications.

Develop a socket-based iPhone app and server!Develop a socket-based iPhone app and server!

Many iOS apps use HTTP to communicate to a web server, because it’s easy, convenient, and well-supported.

However, in some cases you might find the need to go a bit lower level than HTTP, and communicate using TCP sockets to your own custom server.

The advantages of doing this are several:

  • You can send just the exact data you need to send – making your protocol lean and efficient.
  • You can send connected clients data whenever you want, rather than requiring the clients to poll.
  • You can write socket servers without a dependency of a web server, and can write in the language of your choice.
  • Sometimes you just have to use sockets, if you are connecting to a legacy server!

In this tutorial, you’ll get some hands-on experience writing an iPhone app that communicates to a TCP socket server using NSStream/CFStream. Also, you’ll write a simple socket server for it to connect to, using Python!

The iPhone app and chat server will implement chat functionality, so you can chat between multiple devices in real-time!

This tutorial assumes you have a basic familiarity with Python and iOS programming. If you are new to Python programming, check out the official Python tutorial. If you are new to iOS programming, check out some of the iOS tutorials on this site first.

Without further ado, let’s do some socket programming!

Read more

How to Write an iOS App That Uses a Web Service

As an iOS developer, you often need to use a web service from your app.

Sometimes you need to use a web service that someone else has written, and sometimes you need to use one of your own!

In this tutorial, you’ll get hands-one experience with using web services, by writing an iOS app that communicates with a simple web service that allows you to redeem promo codes to unlock extra content.

This tutorial is the second and final part of a two part series on custom web services. If you are curious how to develop the web service yourself, check out the first part of the series for full details!

You don’t necessarily have to set up the web service yourself for this tutorial – you can use the one I’ve already set up if you’d like.

This tutorial assumes you have basic familiarity with programming for iOS. If you are new to iOS development, you may wish to check out some of the other tutorials on this site first.

Read more

How To Write A Simple PHP/MySQL Web Service for an iOS App

As an iPhone/iPad developer, it can be really useful to be able to write your own simple web services that integrate with your apps.

For example, you may wish to display some news updates that come from your web server, and display it on startup. Or perhaps store some user data “in the cloud”. Your imagination is the only limit!

In this first tutorial in this two-part series, you’ll go step-by-step through the process of creating a simple web service, based on a promo code system I included in my latest app, Wild Fables. In the next part of this series, you’ll write an iOS app that integrates with this web service!

To run through all of the steps on this tutorial, you’ll need a web server with MySQL and PHP. If you do not have a web server already, you have three options:

  • If you want to enable Apache/MySQL/PHP directly on your Mac (for free), there are lots of good guides out there, here’s one I found with a quick Google search.
  • If you want to rent a web server online (usually for $$), there are many good choices out there, but the one I personally use (and enjoy) is Linode – check this tutorial for more information.
  • And if you’re just too lazy to do either of the above, you can just read through the steps below, and use the web service I’ve already made in part 2 of series :]

You don’t necessarily need to know PHP or MySQL to go through this tutorial (although it will be helpful!), as the tutorial includes all of the code you’ll need.

Read more

Accessing The Cloud From Cocoa Touch

Everything is moving toward the cloud and unless you’re building calculators, unit converters, or miniature golf score keepers your iPhone app needs to know how to get data from it. In this blog post I intend to demonstrate how to set up a simple server application and how to retrieve data from it and post data to it using Cocoa Touch. I have chosen to use PHP on the server side because of it’s simplicity and ubiquity, and because I’ve know it, somewhat. You should, however, be able to implement something similar using your server side language of choice.

In many cases when you go to access remote data, you do so through a web service API. While services based on such technologies as SOAP or XML-RPC are standards that provide reasonable methods for retrieving and updating data, REST seems to be the methodology gaining the most ground lately. For our purpose in this post I won’t get into great detail of how to implement a REST base web service as, again, REST is not a specific implementation but rather a methodology. (Read up on it elsewhere if you don’t understand what this means). However, I will talk about it briefly so that you can get on the right path for doing your own REST implementation.

Read more