How To Push Out Notifications Locally Based On Time

There are times when you want to notify the user that an important event has occurred or will occur.

Push notifications are a great way to notify the user that an event has occurred and became a staple feature immediately after they were added into the iOS sdk.

Now local notifications are available that allow you to push a notification to the device that your app is running on based on time, the notifications can even be recurring.

Brandon Treb has written a great step-by-step tutorial on exactly how to do just that, which you can find here:
iPhone Programming Tutorial Notifications

Thanks for reading, if you like this please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Blocks – An Interesting Objective-C Addition In iOS 4

Blocks are a feature of the C language that have been added to the iPhone and iPad sdk with iOS 4.

What they allow you to do are create usable “blocks” of code that you can pass along like any object. This probably sounds a lot like a function, and they are very similar, but there is a significant difference in that they “close” around variables that are in scope before a block is declared.

I know this sounds odd, and you might be wondering when you’ll need to use them, but they certainly have their uses as there are definitely times when you will want a small block of reusable code.

You can find a complete tutorial from Mike Clark here that explains things better here:
Using Blocks In iOS 4

If you liked this, please share it!

[Via Joost Schuur]

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Beginner iPhone Action Game Programming Tutorial

Welcome to my iPhone action game tutorial. This is a step by step tutorial for creating an iPhone action game.

You can see the result of a game running the code in the video below:

The graphics are a bit different with the tutorial (as some of those in the video are being used in an actual project) but that is the result of running the actual code within the tutorial.

Specificially the tutorial features:

  • Loading/Placing Images
  • Animation
  • Touch Events
  • Text
  • Sound Effects
  • Background Music
  • Buttons
  • Resetting The Game

Now before we start there are a few pre-requisites. You should have a basic understanding of Objective-C and will need a Mac with the iPhone SDK installed. The game was created using iPhone SDK 4.0, and the Sparrow Framework. Also note that I created this to be as easy to follow as possible so I used a minimum number of classes/methods to make it as easy as possible for a beginner to follow – I’ve even exclusively used autorelease objects  so you don’t need to worry about memory management (one of the facets of Objective-C many beginners have trouble with).

In case you’re wondering why I chose to go the route of using the Sparrow Framework it’s because I believe it is the easiest iPhone game development framework available for free for a beginner to start with, and it has already been used in a number of games in the app store.

Please share this tutorial by tweeting it or sharing using one of the buttons at the bottom.  If you have a Dzone account you can vote it up here!

You can navigate through the tutorial by using the page numbers at the bottom of each page.

If you’d like to jump right in you can download a project with all the resources loaded in here.

At the very end of the tutorial you will find the completed project with extensive comments, and at the end of every page you will find a project file that will bring you up to that point of the tutorial.

Otherwise if you’d like to go the route of installing Sparrow, and setting everything up you can visit the Sparrow Framework getting started page here which explains the process of setting up an Xcode project that utilizes the Sparrow Framework. You can get just the game assets (graphics/sound) here.

The tutorial is definitely not perfect, and there are probably some spelling/grammar mistakes, but it is the most extensive single tutorial I’ve seen around and might never be released if I tried to perfect it :)

The first thing we’re going to do is start the game scene by displaying in a background image, adding the score and level text, and playing some music.  Go to page 2 by clicking that number at the bottom of this article to go to that page.

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

The Best Resources In iOS Development August 3rd 2010 (For Week 07/24-07/30)

Welcome to another weekly summary.  I’m a bit late with this one as I was finishing up the Beginners iPhone Action Game Tutorial.  If you are looking for an extensive tutorial on creating an iPhone or iPad game I highly suggest you check it out.

Things have gotten a little bit slower with the number of quality resources for iOS developers appearing each week.  I’m guessing it has something to do with the weather.

That being said here are some good ones:

Blocks – An Interesting Objective-C Addition In iOS 4
A good tutorial on how to use C closures that have been added to the iOS sdk.

Great Beginner iPhone And iPad Dev Screencasts
Some good absolute beginner screencasts.  If you are totally new to programming and having trouble you will want to check these out.

Easy Open Source iPhone And iPad Library For Communicating With Web Services
A new library that makes it easier to obtain and parse data from web services.

Easy iPhone Simulator Screenshots With Status Bar Removed
An automatic image cropper to simplify iPhone app image taking.

How To Push Out Notifications Locally Based On Time
A tutorial on the new local timer based push notifications recently added to the iOS sdk.

That’s it, if you find something you like please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Hosting A Beta Test For Your iPhone and iPad Apps

Hosting a beta test for an iPhone or iPad app is often a bit much.  The time spent conducting such a test can be extremely costly.

If you are creating a more advanced app though it can be a necessity, and there are many things you will need to do such as: finding beta testers, sending out ad-hoc builds, guiding people through the install process, and filtering through the different responses.

Ray Wenderlich has written a great article that explores all of these facets and more in detail which you can find here:
How To Host A Beta Test For Your iOS App

Thanks for reading, if you lik this please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Custom iPad UISplitViewController Adds Many Slick Features – Open Source

The UI libraries in the iPhone and iPad sdk are excellent, and it’s rare to find a library that adds many significant features.  I recently came across one such library.

The library I’ve come across enhances the UISplitViewController on the iPad adding great features such as the ability to reposition the master and detail views, change the position of the split so you can resize the views, toggle visibility of the master view, and much more.

Here is a demo video of the enhanced UISplitViewController:

The library is known as MGSplitViewController from Matt Gemmell and can be found on Github here:
MGSplitViewController On Github

You can find the original writeup on it here:
MGSplitViewController For iPad

Thanks for reading, if you like this please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

How To Use Visio As A Level Editor

Laying out levels can be a pain, in fact it can be downright impossible if you don’t have some sort of editor.

I caught this very simple guide on to how to do this using Visio which is very interesting as it is a tool that so many people have.

Here’s the process in a nutshell, export the Visio document convert it to an .xsl file then convert that into a .plist file using a specific XML template and read the contents in using multiple NSDictionary’s.

I’m making the process sound simplistic, but there really isn’t much more to it than that, you will of course need to do your own coding to make sure your game knows how to handle the extracted data :)

You can find more info about this process along with the tools used over at Funky Visions:
Using Visio To Write iPhone Apps. Seriously?

If you liked this, please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

CNBC Feature – Planet of the Apps

Planet of the Apps: A Hand-held Revolution Premiered on January 7th 10pm ET on CNBC. In this program CNBC looked at at how apps have changed our lives, and they meet some of the creators behind them, and figure out just how big a business they really are. For those who missed the CNBC special feature on iPhone Apps, this is 45 minute show is a must see / download. Just search on Youtube for related clippings or if you know where on torrents you can probably download the full episode from – if in USA from Hulu, picrap.com, clicker.com or any TV show streaming site. For more information. Please log onto: www.planetoftheapps.cnbc.com

Click here to view the embedded video.

Music Play in iPhoneOS4

This is the very simple example . In this application we will see how to play music in iPhone oS4.

Step 1: Create a new project in Xcode using View base application. Give the application name “MusicPlay_OS4”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: xpand classes and notice Interface Builder created the MusicPlay_OS4ViewController class for you. Expand Resources and notice the template generated a separate nib, MusicPlay_OS4ViewController.xib, for the “MusicPlay_OS4”.

Step 4: We need to add sound files in the Resources folder. Give the name of the sound files “music.mp3”,”sound.aif”. And also add a backgroung image.

Step 5: We need to add also two frameworks.So select Frameworks -> Add -> Existing Framework -> then select AVFoundation.framework and AudioToolbox.framework.

Step 6: In the MusicPlay_OS4ViewController.h file, we have  importAVFoundation.framework and AudioToolbox.framework. Create a instance of  AVAudioPlayer and UIButton class and create two IBAction method. So make the following changes in the file.

#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>

@interface MusicPlay_OS4ViewController : UIViewController
<AVAudioPlayerDelegate>{
       
        SystemSoundID systemSoundID;
        AVAudioPlayer *player;
        UIButton *StartStopSound;
       
}

@property (nonatomic, retain) IBOutlet AVAudioPlayer *player;
@property (nonatomic, retain) IBOutlet UIButton *StartStopSound;

(IBAction) playSound: (id) sender;
(IBAction) playSong: (id) sender;

Step 7: Double click the MusicPlay_OS4ViewController.xib file and open it to the Interface Builder. First drag the Image View from the library and place it to the View window. Select the image view and bring up Attribute Inspector, select the background image. Drag two Round Rect button from the library and place it to the view window.Give the name of the button “Play Sound “and “Play Song” Connect File’s Owner icon to the View icon and select View. Drag File’s Owner icon to the Play Song button and select StartStopSound. Select the Play Sound button and bring up Connection Inspector and drag from the Touch Up Inside to the File’s Owner icon, select playSound: action. Do the same thing with PlaySong button and select the playSong: action. Now save the MusicPlay_OS4ViewController.xib file, close it and go back to the Xcode.

Step 8: Open the MusicPlay_OS4ViewController.m file and make the following changes in the file.

(void)viewDidLoad {
        NSLog(@"InView did load");
        AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]
                                                                                                                                           pathForResource: @"sound" ofType:@"aif"]],
                                                                         &systemSoundID);
   
       
        player = [[AVAudioPlayer alloc]
                          initWithContentsOfURL:[NSURL fileURLWithPath:
                                                                         [[NSBundle mainBundle] pathForResource:@"music" ofType:@"mp3"]]
                          error:nil];
       
       
        [player prepareToPlay];
       
       
       
}

(IBAction) playSound:(id) sender {
       
        NSLog(@"In Sample");
        AudioServicesPlaySystemSound(systemSoundID);
}

(IBAction) playSong:(id) sender {
       
        if ([[NSString stringWithFormat:@"%@", [StartStopSound titleForState:UIControlStateNormal]] isEqualToString:@"Play Song"]) {   
                [player play]
                [StartStopSound setTitle:@"Stop Song" forState:UIControlStateNormal];   }
        else { 
                [player stop]
                [StartStopSound setTitle:@"Play Song" forState:UIControlStateNormal];  
        }      
}

Step 9: Now compile and run the application in the Simulator.

You can Download Source Code from here MusicPlay_OS4

Distimo Mobile Report – July 2010

This report covers the Apple App Store for iPad and iPhone (with specific focus on in-app purchases), as well as BlackBerry App World (Worldwide), Google Android Market, Nokia Ovi Store, Palm App Catalog and Windows Marketplace for Mobile for June 2010 in the United States. The major findings are:

* The percentage of applications with in-app purchases is significantly higher in the Apple App Store for iPad (10%) than in the Apple App Store for iPhone (2%). The Games and Social Networking categories in both stores have the highest proportion of applications with in-app purchases available.

* The most successful free applications that monetized using in-app purchases this month in the Apple App Store for iPhone are MobiTV (MobiTV), ESPN 2010 FIFA World Cup (ESPN) and Tap Fish (BayView Labs).

* The most successful paid applications that monetized using in-app purchases this month in the Apple App Store for iPhone are Guitar Hero (Activision Publishing, Inc.), TomTom U.S.A. (TomTom International BV) and Call of Duty: World at War: Zombies II (Activision Publishing, Inc.).

* Mirroring the Distimo report covering May 2010, Pages and iBooks, published by Apple Inc, are again the number one paid and free applications on the Apple App Store for iPad, respectively.

* Three out of the ten most popular applications in the Apple App Store for iPhone were published by Electronic Arts.

* Quickoffice Connect Mobile Suite for iPad entered the top 10 highest ranked paid applications chart in the 6th position. It was the top grossing application in the Apple App Store for iPad after Pages by Apple Inc.

* Nine out of the ten most popular paid applications on the Apple App Store for iPhone are Games, however only two out of the ten most popular free applications are Games. In the Nokia Ovi Store, seven out of ten of the most popular paid applications are Games, while only three out of ten of the most popular free applications are Games.

You can download the report here.

Change View in iPad

In this application we will see how to change view in iPad.

Step 1: Create a Window base application using template. Give the application name “Windowbase_iPad”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: xpand classes and notice Interface Builder created the Windowbase_iPadAppDelegate class for you. Expand Resources and notice the template generated a separate nib, MainWindow.xib, for the “Windowbase_iPad”.

Step 4: We need to add two images in the resource folder. Give the name of the resources “1-1.png”,”2-1.png”.

Step 5: We have added QuartzCore.framework, select Frameworks -> add -> Existing frameworks -> selectQuartzCore.framework.

Step 6: In the Windowbase_iPadAppDelegate.h file, we have added instances of UIView and UIImageView class, and create one IBAction method. So make the following changes in the file.

#import <UIKit/UIKit.h>

@interface Windowbase_iPadAppDelegate : NSObject <UIApplicationDelegate> {
   
        UIWindow *window;
        UIView  *subView;
        UIImageView *view1;
        UIImageView *view2;
        BOOL change;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UIView  *subView;

(IBAction)ChangeView:(id)sender;

Step 7: Double click your MainWindow.xib file open it to the Interface Builder. Open the the window and drag view from the library and place it to the window. Next drag Toolbar from the library and place it buttom of the view window. Now select ViewChangeAppDelegate, and bring up connection inspector. Select from subView to the view, and ChangeView to the BarButtonItem. Now save your .xib file and go back to the Xcode.

Step 8: Open the Windowbase_iPadAppDelegate.m file and make the following changes in the file.

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
       
        UIImage *image1 = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1-1.png" ofType:nil]];
        view1 = [[UIImageView alloc] initWithImage:image1];
        UIImage *image2 = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"2-1.png" ofType:nil]];
        view2 = [[UIImageView alloc] initWithImage:image2];
        view2.hidden = YES;
        [subView addSubview:view1];
        [subView addSubview:view2];
        change = NO;
       
        [window makeKeyAndVisible];
       
        return YES;
}

(void)performTransition
{
       
        CATransition *transition = [CATransition animation];

        transition.duration = 0.75;
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
       
        NSString *types[4] = {kCATransitionMoveIn, kCATransitionPush, kCATransitionReveal, kCATransitionFade};
        NSString *subtypes[4] = {kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom};
        int rnd = random() % 4;
        transition.type = types[rnd];
        if(rnd < 3)     {
                transition.subtype = subtypes[random() % 4];
        }
       
        change = YES;
        transition.delegate = self;
       
        [subView.layer addAnimation:transition forKey:nil];
       
        view1.hidden = YES;
        view2.hidden = NO;
       
        UIImageView *tmp = view2;
        view2 = view1;
        view1 = tmp;
}

(void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
        change = NO;
}

(IBAction)ChangeView:(id)sender
{
        if(!change)
        {
                [self performTransition];
        }
}

Step 9: Now compile and run the application in the Simulator.

You can Download SourceCode from here Windowbase_iPad

Make $400 to $5000 DAILY from Ad Revenues With Your Free App

The iPhone Apps get-rich-quick landscape is best suited for one of two people development shops. However, some companies are also making good revenues – specifically from in-app advertising.

In the report below, AdWhirl says that top apps can make $400 to $5,000 per day on ads. The average CPM works out to around $2 per 1000 impressions. It may not look  impressive but its substantially better than the CPM rates at Facebook or MySpace apps.

However – These apps are from the most popular section on the app store… listing within the top 100 free apps. This is what is causing a problem for small developers. You need to crack into the top 100 if you want to get to the $400 daily revenue target.



Adwhirl iPhone Advertising Snapshot



You can access the Adwhirl data report directly here.

Display Splash Screen in iPad

In this application we will see how to display Splash Screen in iPad.

Step 1: Create a View base application using template. Give the application name “DisplaySplash_iPad”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Expand classes and notice Interface Builder created the DisplaySplash_iPadViewController class for you. Expand Resources and notice the template generated a separate nib, DisplaySplash_iPadViewController.xib, for the “DisplaySplash_iPad”.

Step 4: We need to add one resource in the resource folder for display splash.

Step 5: In the DisplaySplash_iPad.h file, we have created instance of UIView class and two methods. So make the following changes in the file.

#import <UIKit/UIKit.h>

@interface DisplaySplash_iPadViewController : UIViewController {

        IBOutlet UIView *displaySplashScreen;
       
}

(void)displayScreen;
(void)removeScreen;

Step 6: Double click the DisplaySplash_iPadViewController.xib file and open it to the Interface Builder. Drag the view from the library and place it to the Main Window. Open the second view icon from the MainWindow,drag the image view from the library and place it to the view window,select the view and bring up Attribute Inspector select the image “themes.png”. Select the File’s Owner icon from the MainWindow and bring up Connection Inspector, drag from the displayScreen to the last view icon and connect File’s Owner icon to the view. Now save it , close it and go back to the Xcode.

Step 7: Open the DisplaySplash_iPad.m file and make the following changes in the file.

(void)displayScreen
{
       
        UIViewController *displayViewController=[[UIViewController alloc] init];
        displayViewController.view = displaySplashScreen;
        [self presentModalViewController:displayViewController animated:NO];
    [self performSelector:@selector(removeScreen) withObject:nil afterDelay:6.0];
       
       
}

(void)removeScreen
{
        [[self modalViewController] dismissModalViewControllerAnimated:YES];
}

Step 8 : Now compile and run the application in the Simulator.

You can Download SourceCode from here DisplaySplash_iPad

Mobile Report by Distimo, June 2010 – A Must Read for Business Intelligence Data

This report covers the Apple App Store for iPad, the Apple App Store for iPhone, BlackBerry App World (Worldwide), Google Android Market, Nokia Ovi Store, Palm App Catalog and Windows Marketplace for Mobile for May 2010 in the United States.

The major findings are:

More than 50% of applications are priced below or equal to $2.00 in all stores, with the exception of BlackBerry App World and Windows Marketplace for Mobile.

The average price of all paid applications and the 100 most popular paid applications in the Apple App Store for iPad ($4.65) is higher than in the Apple App Store for iPhone ($4.01). However, the average price of the 100 top grossing applications is higher on the Apple App Store for iPhone.

Google Android Market has the largest share of free applications (57%) and Windows Marketplace for Mobile has the smallest (22%).

Twitter, Inc. published their native application in the Apple App Store and Google Android Market, becoming the monthly number 10 free application in the Apple App Store for iPhone, and the number 6 free application in Google Android Market.

Nine out of the ten most popular free applications and eight out of ten most popular paid applications in the Apple App Store for iPhone are games.

In the competitive e-reader market, both the iBooks application by Apple, Inc., and the Kindle application by Amazon.com are ranked among the 10 most popular free applications in the Apple App Store for iPad. Apple’s application is ranked number one however, and Amazon’s application is ranked number ten.

Five out of the ten most popular free applications in Windows Marketplace for Mobile are published by Microsoft Corporation.

You may download the entire report for free here!

Display WebPage and AudioFile play in TabBar Application

This is the TabBar application. In this application we will see how to display Web page and play audio file in the iPad. We will create this application using TabBar Application Template.

Step 1: Create a TabBar application using template. Give the application name “Tabbar_Videoplay_iPad”.

Step 2: code automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Xpand classes and notice Interface Builder created the TabBarApplication_iPadViewController class for you. Expand Resources and notice the template generated a separate nib,TabBarApplication_iPadViewController.xib, for the “TabBarApplication_iPad”.

Step 4: We need to add UIViewController class in the project . Select classes -> Add -> New Files -> Select UIViewController class and give the class name “AudioPlayViewController”. Select corresponding .xib file and targeted for iPad.

Step 5: We have added AudioToolbox and AVFoundation framework in the Frameworks folder.

Step 6: We need to add two music file in the resource folder. Give the name of the music file “sound.aif”,”music.mp3″.

Step 7: In the FirstViewController.h file we have created instance of UIWebView class . So make the following changes in the file.

#import <UIKit/UIKit.h>

@interface FirstViewController : UIViewController {
  IBOutlet UIWebView *webDisplay;
}
@property(nonatomic,retain) UIWebView *webDisplay;

Step 8: Double click the MainWindow.xib file and open it to the Interface Builder. Select the FirstViewController from the TabBar Controller and bring up Attribute Inspector and delete the NIB name . Now drag the WebView from the library and place it to the view window. Select the first tab from the view window and bring up Connection Inspector and connect webDisplay to the Web View. Save the MainWindow.xib file and close it and go back to the Xcode.

Step 9: Open the FirstViewController.m file and make the following changes in the file.

(void)viewDidLoad {
       
        NSString *urlAddress = @"http://www.google.com";
        NSURL *url = [NSURL URLWithString:urlAddress];
        NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
        [webDisplay loadRequest:requestObj];
       
    [super viewDidLoad];
}

Step 10: In the AudioViewController.h file , we have import AudioToolbox and AVFoundation framework. Create an instance of  AVAudioPlayer and UIButton class. Define two IBAction method. So make the following changes in the file.

#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>

@interface AudioPlayViewController : UIViewController  <AVAudioPlayerDelegate> {

        SystemSoundID systemSoundID;
        AVAudioPlayer *player;
        UIButton *StartStopSound;
       
}

@property (nonatomic, retain) IBOutlet AVAudioPlayer *player;
@property (nonatomic, retain) IBOutlet UIButton *StartStopSound;

(IBAction) playSound: (id) sender;
(IBAction) playSong: (id) sender;

Step 11: Double click the AudioPlayViewController.xib file and open it to the view window. First drag the two Round Rect from the library and place it to the view window and give the name “Play Sound” , “Play Song”. Select the  ”Play Sound” button and bring up connection Inspector and drag Touch Up Inside to the File Owner icon select playSound: action. Do the same thing for the “Play Song”  button and select the playSong: action. Connect File’s Owner icon to the “Play Song” button and select StartStopSound. Now save the AudioPlayViewController.xib file, close it and go back to the Xcode.

Step 12: Open the AudioPlayViewController.m file and make the following changes:

(void)viewDidLoad {
        NSLog(@"InView did load");
        AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]
                                                                                                                                           pathForResource: @"sound" ofType:@"aif"]],
                                                                         &systemSoundID);
   
       
        player = [[AVAudioPlayer alloc]
                          initWithContentsOfURL:[NSURL fileURLWithPath:
                                                                         [[NSBundle mainBundle] pathForResource:@"music" ofType:@"mp3"]]
                          error:nil];
       
       
        [player prepareToPlay];
       
       
       
}

(IBAction) playSound:(id) sender {
       
        NSLog(@"In Sample");
        AudioServicesPlaySystemSound(systemSoundID);
}

(IBAction) playSong:(id) sender {
       
        if ([[NSString stringWithFormat:@"%@", [StartStopSound titleForState:UIControlStateNormal]] isEqualToString:@"Play Song"]) {   
                [player play]
                [StartStopSound setTitle:@"Stop Song" forState:UIControlStateNormal];   }
        else { 
                [player stop]
                [StartStopSound setTitle:@"Play Song" forState:UIControlStateNormal];  
        }      
}

Step 13: Double click the MainWindow.xib file and open it to the Interface Builder. Select the ViewController from the TabBar Controller  in MainWindow and bring up Identity Inspector and change the class name into AudioPlayViewController and bring up Attribute Inspector, set the NIB name into “AudioPlayViewController”. Now save the MainWindow.xib file, close it and go back to the Xcode.

Step 14: Now Compile the application and run it in the Simulator.

You can Download SourceCode from here Tabbar_Videoplay_iPad