O'Reilly logo

Beginning iOS Game Center and Game Kit: For iPhone, iPad, and iPod touch by Kyle Richter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Putting It Together

In this chapter, we modify our existing code base from Chapter 8. Begin there by creating a new audio session for your voice chat service. Add the following block of code to the UFOGameViewController.m viewDidLoad: method. In addition, you need to add the AVFoundation.framework to your project. Modify the relevant section of the viewDidLoad method to match the following.

if (self.gameIsMultiplayer == NO) {     for (int x = 0; x < 5; x++)     {         [self spawnCow];     }     [self updateCowPaths]; } else {     [self generateAndSendHostNumber];     NSError *error = nil;     AVAudioSession *audioSession = [AVAudioSession sharedInstance];      [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&error]; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required