Wednesday, August 31, 2011

Xcode and #pragma mark

#pragma mark directives in code to help with organization as implementation files grow.
#pragma mark is simple to use,

for example, insert the following to call out initialization code:

#pragma mark -

#pragma mark Initialization

Once this is in place, the Functions Menu (in the navigation bar) which shows a list of locations within a source file (e.g. definitions of classes, functions and methods) will display a new marker with the label "Initialization." The code in line 1 will add a line separator inside the Functions Menu, in this example, with the line appearing above the "Initialization" marker.

The figure that follows shows an example of how you might use #pragma mark to divide up various sections of your code.

Two notes:
  1. You cannot have a space after the "-" in the #pragma mark -

  2. If your code does not appear as expected (e.g. the separator does not appear), check that ‘Sort list alphabetically’ is not checked in the Code Sense preference settings.

Tuesday, August 23, 2011

How To Install iOS 5 (Beta) On Your iPhone, iPad or iPod Touch? (Developers Only)

imagesfdsf1 How To Install iOS 5 (Beta) On Your iPhone, iPad or iPod Touch? (Developers Only)
iOS 5 beta is now available for developers to install on their iPhone, iPad or iPod touch devices. 

How to install iOS 5 beta?

1) Head to Apple Developer Center and open iOS Dev Center page.
2) Click on iOS Beta SDK link.
3) Download “Xcode and iOS SDK 5 Beta ” and install it.
4) Download “iTunes 10.5 Beta” and install it.
5) Download “iOS 5 beta (x)” – iPhone, iPad and iPod Touches have own iOS 5 beta files, so download the that suits your devices.
6) Plugin your device to your Mac.
7) Take backup of your data in iTunes 10.5 beta If you haven’t already done this before.

Register your iPhone/iPad/iPodTouch: If you haven’t already registered your devices with Apple Developer iOS Provisioning Portal then first you have to register your device. Just go to “Provisioning Portal” on Apple Developer portal and click on “Devices” to add your devices.

9) Now run the iOS 5 beta file that you downloaded. (It ends with .dmg). It will show the file that ends with *.ipsw. For now just remember where the file exists.
10) Open XCode. Open “Organizer” within XCode. Window -> Organizer
11) On the left part of window you will see your device. Select it. If it’s not already in development mode, you will see option to “Use for Development”.
12) Click on “Software Version”, Select “Others” and select the iOS 5 beta file that ends with “*.ipsw” extension.

Screen shot 2011 06 07 at 1.49.51 PM 300x129 How To Install iOS 5 (Beta) On Your iPhone, iPad or iPod Touch? (Developers Only)

13) Now click on “Restore ”
14) It will take few minutes and your device will be ready to use with iOS 5

How to Install iOS 5 Beta on the iPhone Without Apple Dev Account

A Gizmodo reader has discovered a “backdoor” that allows you to install iOS 5 on the iPhone and enjoy all of its features without having to register its UDID with Apple first…
This workaround takes advantage of a Voice Over security flaw within the activation screen. Here’s how to do it:

First, you’ll need the iOS 5 firmware, which you’ll find with a quick Google search. Now, update your device in iTunes by holding the ‘Option’ key while you click the ‘Check for Update’ button, then select your iOS 5 IPSW file. When your device reboots, you’ll be greeted by a new activation screen.

Now follow these steps:
1. Triple click the home button. This will activate Voice Over.
2. Triple click the home button and Emergency Call will appear.
3. Click on Emergency Call and, while it’s switching, swipe your three fingers down.
4. The Notification Center will appear!
5. Click on the Weather widget. The Weather app will load.
6. Click on the home button to exit to the iPhone’s springboard.
Your device should now be activated and fully functional with the iOS 5 firmware.
While this is incredibly cool, and a great way to get your hands on iOS 5 early, we don’t recommend you try this on your primary device. If anything goes wrong, you’re stuck with an iOS 5 beta that you can’t activate, and an iOS device that will be nothing more than an expensive paperweight until this Fall.

Monday, August 8, 2011

How to Play Video in iPhoneOS4

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

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 VideoPlayiPhoneOS4ViewController class for you. Expand Resources and notice the template generated a separate nib,VideoPlayiPhoneOS4ViewController.xib, for the “VideoPlayiPhoneOS4”.

Step 4: We need to add MediaPlayer.framework in the Frameworks folder. Select-> Frameworks folder -> Add ->Existing Frameworks -> then select MediaPlayer.framework.

Step 5: In the VideoPlayiPhoneOS4ViewController.h file , we have created instance of MPMoviePlayerController class, that manage the playback of a movie from a file or from the network, and create a instance of NSURL class . So make the following changes in the file.

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface VideoPlayiPhoneOS4ViewController : UIViewController {
    MPMoviePlayerController *moviePlayer;
        NSURL *movieURL;

Step 6: Open the VideoPlayiPhoneOS4ViewController.m file and make the following changes:

        NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"" ofType:nil];
        NSURL *url = [NSURL fileURLWithPath:urlStr];
        moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
        [self.view addSubview:moviePlayer.view];
        moviePlayer.view.frame = CGRectMake(0, 0, 300, 400);
        [moviePlayer play];

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

You can Download SourceCode from here VideoPlayiPhoneOS4