Archive for the ‘iPhone Dev’ Category

To sending params such as index.html?param1=xx&param2=yy, we can use window.location.search.

Example:

var params = window.location.search.slice(1).split(“&”);
for(var p=0; p<params.length; p++) {
var pair = params[p].split("=");
var name = pair[0] ;
var value = pair[1];
// What you want to do with name and value…
if( name == 'param1' ){
//
}else if(name == 'param2'){
//
}
}

Comparison of location estimation accuracy in Wi-Fi – indoor positioning system
1. Introduction:

Indoor positioning technology is an important issue to be addressed for providing any kind of location based services. There were lot of approaches for this technology by the user of active sensors like active badge, active bat, etc. (Hightower and Borriello, 2001), and some approaches use the in-building Wi-Fi networks for indoor positioning. The use of Wi-Fi signals as a potential positioning system within buildings has opened doors for many applications. Lot of research is being undertaken in this domain to find a more viable solution of location positioning using the Wi-Fi signals within the building with higher accuracy. This is because of the ubiquitous availability of Wi-Fi signals in almost all the buildings, so no additional hardware is required to install a positioning system in the buildings.

(more…)

This is a post by iOS Tutorial Team member Matthijs Hollemans, an experienced iOS developer and designer.

In iOS, apps can’t do a lot in the background. Apps are only allowed to do limited set of activities so battery life is conserved.

But what if something interesting happens and you wish to let the user know about this, even if they’re not currently using your app?

For example, maybe the user received a new tweet, their favorite team won the game, or their dinner is ready. Since the app isn’t currently running, it cannot check for these events.

Luckily, Apple has provided a solution to this. Instead of your app continuously checking for events or doing work in the background, you can write a server-side component to do this instead.

And when an event of interest occurs, the server-side component can send the app a push notification! There are three things a push notification can do:

  • Display a short text message
  • Play a brief sound
  • Set a number in a badge on the app’s icon

You can combine these however you see fit; for example, play a sound and set the badge but not display a message.

In this 2-part tutorial series, you’ll get to try this out for yourself by making a simple app that uses APNS!

In this first part, you’ll learn how to configure your app to receive push notifications and receive a test message.

This tutorial is for intermediate or advanced iOS developers. If you are still a beginner to iOS, you should check out some of the other tutorials on this site first. Also, it’s highly recommended that you review these two tutorials first (or have equivalent knowledge):

(more…)

iOS File System Basics

Posted: March 4, 2012 in iPhone Dev

The file systems in Mac OS X and iOS handle the persistent storage of data files, apps, and the files associated with the operating system itself. Therefore, the file system is one of the fundamental resources used by all processes.

The file systems in Mac OS X and iOS are both based on the UNIX file system. All of the disks attached to the computer—whether they are physically plugged into the computer or are connected indirectly through the network—contribute space to create a single collection of files. Because the number of files can easily be many millions, the file system uses directories to create a hierarchical organization. Although the basic directory structures are similar for iOS and Mac OS X, there are differences in the way each system organizes apps and user data.

Before you begin writing code that interacts with the file system, you should first understand a little about the organization of file system and the rules that apply to your code. Aside from the basic tenet that you cannot write files to directories for which you do not have appropriate security privileges, apps are also expected to be good citizens and put files in appropriate places. Precisely where you put files depends on the platform, but the overarching goal is to make sure that the user’s files remain easily discoverable and that the files your code uses internally are kept out of the user’s way.

(more…)

// Disable the idle timer
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];

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!
(more…)

This article describes the file naming conventions for the Slippy Map application.

  • Tiles are 256 × 256 pixel PNG files
  • Each zoom level is a directory, each column is a subdirectory, and each tile in that column is a file
  • Filename(url) format is /zoom/x/y.png

The slippy map expects tiles to be served up at URLs following this scheme, so all tile server URLs look pretty similar.

Contents

[hide]

(more…)

This is the second part of a two part tutorial series on creating a simple networked game with Game Center matchmaking.

In the first part of the tutorial series, you learned how to enable Game Center for your app and find matches with other players using the built-in GKMatchmakerViewController.

In this second and final part of the tutorial series, you’ll learn how to look up player aliases, how to send and receive data between games, and how to support invites.

In the end, you’ll have a fully functional (but simple) networked game that uses Cocos2D and Game Center that you can play with your friends!

If you haven’t got it already, start by downloading the sample project where we left it off in the last tutorial.

(more…)

Create a multiplayer racing game with Cocos2D and Game Center!

I’m experimenting with a new way of writing tutorials – by taking suggestions by you guys!

In the sidebar to the right (scroll down a bit), you’ll find a new section where you can vote for which tutorial comes next.

In the first vote, a bunch of you guys said you wanted a tutorial about making a simple multiplayer game (88 of you to be exact!) – so here you go! :]

In this 2-part tutorial series, you’ll make a simple 2-player networked game with Cocos2D and Game Center matchmaking.

The game you’ll be working with is very simple. It’s a racing game with a dog vs. a kid – tap as fast as you can to win!

This tutorial assumes you are already familiar with the basics of using Cocos2D. If you are new to Cocos2D, you might want to check out some of the other Cocos2D tutorials on this site first.

Note: To fully get through this tutorial series, you must be a registered member of the iOS developer program so you can enable your app to use Game Center. Also, you will need at least one physical device (so that you can run one copy on the simulator and one on your device). Finally, you will need at least two different Game Center accounts for testing (don’t worry, you can create more than one for free, you just need another email address).

Ready? On your mark, get set, GO!

(more…)

Creating a book for Baker is like building a website, all you need to start is:

Assuming the points above have been taken care of, the next step is answering these questions:

  1. How will you divide your book in HTML pages?
    Baker books are composed by multiple HTML pages. Since HTML pages aren’t limited in length you can choose to have a whole chapter of your book on a single page.
  2. Which device will you target?
    Baker supports both iPhone/iPod and iPad, choose which platform you want to target and design your book accordingly.
  3. Which orientation will you target?
    Baker supports both landscape and portrait orientation, choose the one you like for your book… or provide a beautiful style for both.

If you have an answer for all these questions then you can really start to create your book. Remember that you can take advantage of all the HTML5 and CSS3 features and all the JavaScript libraries available for WebKit. If you want to test how your work is coming along, try your pages in Safari Mobile: Baker will render them in the same way.

(more…)