Monday, May 30, 2011

How To Stop iTunes Automatically Syncing Your iPhone, iPod or iPad

iTunes Auto Sync Slowing You Down?

If you’re wondering how you can stop iTunes from automatically kicking off the sync + backup + update process when you plug your iOS device in then look no further.

By holding down the Shift + Control keys (Windows) or Command + Option keys (Mac) and then plugging your iPad, iPhone or iPod into your USB port you will tell iTunes not to sync!

If you happen to miss it and sync kicks off anyway, either slide the unlock slider on your device or hit the eject symbol in iTunes and your device will gracefully stop syncing and disconnect.

This was tested using both an iPad 2 and an iPhone 3GS on iTunes 10.2 (Mac).

Wednesday, May 25, 2011

iOS - File Sharing



File Sharing requires

  • The latest version of iTunes
  • Mac OS X v10.5.8 or later or an up-to-date version of Windows XP, Windows Vista, or Windows 7
  • An iOS device (with the latest version of iOS)
  • An iOS application that supports File Sharing

How to copy files using File Sharing

  1. Connect your iOS device to your computer using the included Dock Connector to USB cable.
  2. Launch iTunes 9.1 or later on your computer.
  3. Select your iOS device from the Devices section of iTunes.

    iTunes Devices section
  4. Click the Apps tab and scroll down to the bottom of the page.

How to Find Your iPhone’s Unique Identifier (UDID)


What is the UDID?


Each iPhone or iPod Touch has a Unique Device Identifier (UDID),
which is a sequence of 40 letters and numbers that is specific to your
device. It’s like a serial number but much harder to guess. It
will look something like this:
2b6f0cc904d137be2e1730235f5664094b831186.


Why do we need the UDID?


Your iPhone can only install programs that are approved by Apple.
Applications in the App Store have been approved by Apple for general
distribution, but beta customers get to try the app before it’s in the
store. We register your UDID with Apple so they can approve our
application especially for your iPhone.


How do I get my UDID?


You can copy/paste your UDID from iTunes or email it directly from
your device by using a free app from the App Store.

Tuesday, May 24, 2011

MTOM - OVER VIEW

MTOM OVERVIEW

With web services-based SOA now being deployed across Global 2000
enterprises, transmitting attachments such as MRI Scans, X-Rays, Design
Documents and Business Contracts using SOAP messages has become a
common practice. SOAP Message Transmission Optimization Mechanism (MTOM),
is a W3C Recommendation designed for optimizing the electronic
transmission of attachments. Through electronic transmission of
documents, corporations can realize significant cost savings and better
service levels by eliminating the use of postal mail. Paper-based
manual tasks can be replaced with simple and efficient electronic
processes where binary data can be transmitted between organizations
through standards such as MTOM.

MTOM provides an elegant mechanism of efficiently transmitting
binary data, such as images, PDF files, MS Word documents, between
systems. The Figure below shows the steps involved in transmitting data
between a Consumer and Producer using MTOM.



MTOM Process

The Consumer application begins by sending a SOAP Message that contains complex data in Base64Binary encoded format. Base64Binary data type represents arbitrary data (e.g., Images, PDF files, Word
Docs) in 65 textual characters that can be displayed as part of a SOAP
Message element. For the Send SOAP Message Step 1 in the Figure above, a sample SOAP Body with Base64Binary encoded element <tns:data> is as follows:

Monday, May 23, 2011

Understanding MTOM

MTOM combines the composability of Base 64 encoding with the transport efficiency of SOAP with Attachments. Non-XML data is processed just as it is with SOAP with Attachments SWA – the data is simply streamed as binary data in one of the MIME message parts. (The MTOM processing model is described in greater detail below.)

MTOM is composed of three distinct specifications:

Monday, May 16, 2011

How to Get the RGB Color Code from hex code

- (UIColor *) RGBColorCodeWithHCode: (NSString *) Hexcode{
NSString *colorstr = [[Hexcode stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
// String should be 6 or 8 characters
if ([colorstr length] < 6)
return [UIColor blackColor];
// strip 0X if it appears
if ([colorstr hasPrefix:@"0X"])
colorstr = [colorstr substringFromIndex:2];
if ([colorstr length] != 6)
return [UIColor blackColor];
// Separate into r, g, b substrings
NSRange range;
range.location = 0;
range.length = 2;
NSString *rcolorString = [colorstr substringWithRange:range];
range.location = 2;
NSString *gcolorString = [colorstr substringWithRange:range];
range.location = 4;
NSString *bcolorString = [colorstr substringWithRange:range];
// Scan values
unsigned int red, green, blue;
[[NSScanner scannerWithString: rcolorString] scanHexInt:&red];
[[NSScanner scannerWithString: gcolorString] scanHexInt:&green];
[[NSScanner scannerWithString: bcolorString] scanHexInt:&blue];

return [UIColor colorWithRed:((float) red / 255.0f)
green:((float) green / 255.0f)
blue:((float) blue / 255.0f)
alpha:1.0f];
}

Wednesday, May 11, 2011

iPad Modal View Controllers

Modal view controllers are well documented in the View Controller Programming Guide for iPhone OS but here is a quick recap of how to present and dismiss a modal view. To keep things simple I will cover the steps for presenting the modal view when a button is pressed on a master view controller. When the button is pressed we need to create and show a detail view controller that contains a button that the user can use to dismiss the modal view controller. The NIB file for the detail view controller is trivial in this example consisting of just a single view containing a text label.

Allocating and showing the detail view controller is straightforward:

- (void)buttonAction:(id)sender {
// Create the modal view controller
DetailViewController *viewController = [[DetailViewController alloc]
initWithNibName:@”DetailViewController” bundle:nil];
// We are the delegate responsible for dismissing the modal view
viewController.delegate = self;
// Create a Navigation controller
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:viewController];
// show the navigation controller modally
[self presentModalViewController:navController animated:YES];
// Clean up resources
[navController release];
[viewController release];
}


Tuesday, May 10, 2011

iPhone-iPad Development Tips

1. Screen Resolution;

iPhones are available in different screen resolutions; It is in 320×480 and the iPhone 4 screen resolution is 640×960. Same in caes of iPad; Currently it is 1024×768 and iPad 2 likely to have 2048×1536 screen resolution; So we need to care about this while playing with layouts; Here is a code to determine screen size;

CGRect currentScreen = [[UIScreen mainScreen] bounds];
currentScreen.size.width will return the width of screen;
currentScreen.size.height will return height of screen;

Note: If you rotate your screen to landscape, then height will become width and vise versa;

2. Device Type;

Following piece of code will tell you whether your application is running on iPhone or iPad;

UIDevice* currentDevice = [UIDevice currentDevice];
if(currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
NSLog(@"oh its iPad");
}else{
NSLog(@"This is iPhone");
}

Friday, May 6, 2011

iOS - Architecture


Cocoa Touch Layer - features

Multitasking

Applications built using iOS SDK 4.0 or later (and running in iOS 4.0 and later) are not terminated when the user presses the Home button; instead, they shift to a background execution context. The multitasking support defined by UIKit helps your application transition to and from the background state smoothly.
To preserve battery life, most applications are suspended by the system shortly after entering the background. A suspended application remains in memory but does not execute any code. This behavior allows an application to resume quickly when it is relaunched without consuming battery power in the meantime. However, applications may be allowed to continue running in the background for the following reasons:
  • An application can request a finite amount of time to complete some important task.
  • An application can declare itself as supporting specific services that require regular background execution time.
  • An application can use local notifications to generate user alerts at designated times, whether or not the application is running.
Regardless of whether your application is suspended or continues running in the background, supporting multitasking does require additional work on your part. The system notifies your application as it transitions to and from the background. These notification points are your cue to perform any important application tasks such as saving user data.

Thursday, May 5, 2011

Reading and Writing plists

Reading a plist file from the application bundle just requires a few lines of code, and some error handling. I like to place that code in a nice convenience method like this:
 

- (id)readPlist:(NSString *)fileName {
   NSData *plistData;
   NSString *error;
   NSPropertyListFormat format;
   id plist;

   NSString *localizedPath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"plist"];
   plistData = [NSData dataWithContentsOfFile:localizedPath];
   plist = [NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error];
   if (!plist) {
      NSLog(@"Error reading plist from file '%s', error = '%s'", [localizedPath UTF8String], [error UTF8String]);
      [error release];
   }

   return plist;
}

I’m not too fond of using id as return values or parameters to methods. I prefer stronger type checks, so I typically wrap the readPlist method in two methods that return either an array or a dictionary.

Creating a New Navigation-Based Application

Open Up Xcode



You will be doing all of your development in Xcode. Then close the Welcome window (if it shows up)
Start a new iPhone OS Project
Click Xcode > New Project and a window should pop up like this:



Make sure Application is selected under iPhone OS and then select Navigation-Based Application. Click Choose… It will ask you to name your project.  Type in “Hello World” and let’s get started.

iPhone Programming Tutorial – UITableView Hello World

In this tutorial I will walk to you through creating a simple “Hello World” application using a UITableView for the iPhone.  There are many ways that a Hello World program could be made on the iPhone, I am going to show you the simplest.  This tutorial assumes you have a basic understanding of Objective-C.  Apple has provided a very simple and straight forward tutorial on Objective-C.  You can find it here.
You will learn how to:
This tutorial assumes that you have already installed the iPhone SDK.  If you are unsure how to do this, click and follow the steps.

Debugging Tutorial – Automating Your Tests With A UIRecorder Instrument

If you have ever experienced a bug in your application that took many steps to reproduce, then this tutorial is for you.  By nature, testing and debugging are very tedious processes.  This is especially the case for the iPhone.
Say you have an app that drills down 5-levels deep to some other view.  Now let’s say that you have a bug on that view 5 levels deep.  Your normal method of debugging is:
  • Run the app
  • Tap view 1
  • Tap view 2
  • Tap view 3
  • Tap view 4
  • Tap view 5
  • (Crash)
  • Change some code
  • Repeat
As you can see (and I’m sure have noticed), this sucks.  Well, Kendall Gelner gave a killer talk at 360iDev (which I recently attended) on various debugging tips using Instruments and XCode.  One of the most useful techniques (to me) was how to automate your testing.  Let me show you what I mean.

1. Open up the app you wish to test/debug
2. Launch it in the simulator
3. Open Instruments – This is located in /Developer/Applications/Instruments (just do a spotlight search for it)

simple Navigationbased tutorial

It’s time to start displaying some drinks. You’ll need to make some modifications to both the RootViewController.h and RootViewController.m files

1Declare the drinks array.(in RootViewController.h )

@interface RootViewController : UITableViewController{
NSMutableArray* drinks;
}
@property (nonatomic, retain) NSMutableArray* drinks;
@end
(RootViewController.m)

@synthesize drinks;
-(void)dealloc{

[drinks release];

[super dealloc];

}

Backup iPhone Pictures – Mac Tips

Listen to this episode
When you have problems with your iPhone, you may have no other choice than to RESTORE it back to the factory state. Before you restore, iTunes says it is making a backup of your phone. However, it isn’t making a backup of any photos you have taken with it. So when the phone is restored, all of your photos will be gone. The good news is that If you have your iPhone set to sync your photos with iPhoto automatically when you plug it in, you may be OK. However, if you are like me and choose for the iPhone not to launch iPhoto when you connect it… well, you need to backup those pics.

How to do it:

1. Plug-in your iPhone and launch iPhoto. iPhoto will detect your iPhone, and you can now choose to import all or import selected pictures.
mactips_358_1.png
Doing this will add pictures you have taken with your iPhone into your iPhoto library.

Another Way – Image Capture

You can also use Image Captureimagecapture.png to do the same thing, but not add them to your iPhoto library.
1. Plug-in your iPhone. Launch Image Capture. You can find it in your Applications folder. If you don’t see it there, look in the Utilities folder. Note: On the podcast, I said it will be in the utilities folder… I forgot that it may reside in Applications.
2. Now it will detect your iPhone, and you can choose to Download Some or Download ALL to your Mac.
mactips_358_2.png

ScrollView example for TextField in iPhone

In the application when user input in the textfield then see UITextField is hidden under the keyboard.This problem solved using the ScrollView. So let see how it will be worked.
In this application we will see how to ScrollView worked in our application. This is the very simple application. In the application when user input in the textfield then see UITextField is hidden under the keyboard.This problem solved using the ScrollView. So let see how it will be worked.

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

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

Step 4: Open the ScrollViewExampleViewController.h file, we have added scrollview for scrolling the view,and two textfield for display the textbox. So make the following changes in the file:

#import
@interface ScrollViewExampleViewController : UIViewController {

IBOutlet UIScrollView *scrollview;
IBOutlet UITextField *textField1;
IBOutlet UITextField *textField2;

BOOL displayKeyboard;
CGPoint  offset;
UITextField *Field;
}

@property(nonatomic,retain) IBOutlet UIScrollView *scrollview;
@property(nonatomic,retain) IBOutlet UITextField *textField1;
@property(nonatomic,retain) IBOutlet UITextField *textField2;
 

Features of iPhone4


5 Megapixel Camera with LED Flash

Take beautiful, detailed photos with the new 5-megapixel camera with built-in LED flash. The advanced backside illumination sensor captures great pictures even in low light. And the new front-facing camera makes it easy to take self-portraits.

Creating Digital Mockups For Your Apps




While conceptualizing your App, the first things you need to create is a flow chart of how your App will behave and some reference templates and images that will show you how each screen will look in your App. Here are some tools to help you do this.
While conceptualizing your App, the first things you need to create is a flow chart of how your App will behave and some reference templates and images that will show you how each screen will look in your App.

The first step to doing this is to get hold of a pencil and paper and make some rough sketches. Start by making a list of all the possible screens your app will have and then actually listing the functionality each screen will have. Once you have that, you can proceed to make some dummy mockup sketches. At this point you should focus on the “placement” elements of each screen… that is decide, what goes where. Next you can start to imagine the design elements and look and feel of each screen – and how they will all look similar and connect to one another. A flow chart showing how the connect up – will help. I suggest you get hold of a spiral bound sketch book and not lose sheets of paper, that can easily get misplaced. Any writing pad will also do.

To help you make your hard copy and soft copy drawings, these downloadable documents and plans will help you. They will be useful when you are brainstorming or trying to find the perfect flow for your app and putting the visual elements together.
  • Mock App – Templates for Keynote and Powerpoint
  • Yahoo Design Stencils – Yahoo! Design Stencil Kit version 1.0 is available for OmniGraffle, Visio (XML), Adobe Illustrator (PDF and SVG), and Adobe Photoshop (PNG)
Download each of the above packs and files as they are all must have tools when you or your graphic artist are planning the User Interface or graphic design of your Apps.

Playing Video file in Iphone


Let’s start by looking at a short video of the application. The basic idea to make this work is simple, your video content viewable in your simulator.
Step 1: Create a new project from Xcode using View-base application.
Step 2: We need to add some code in the header file.
#import <MediaPlayer/MediaPlayer.h>
#import <UIKit/UIKit.h> @interface Tabbar1ViewController : UIViewController { MPMoviePlayerController *moviePlayer; NSURL *movieURL; }
Step 3: Now you add MediaPlayer.framework in your framework folder.Only shows up in the iPhone SDK frameworks folder, at  /Developer/platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/Frameworks.

iPhone SDK Tip: Firing custom events when a link is clicked in a UIWebView

Well I have been asked this a few times and I can see how it would be a very helpful addition to theUIWebView’s feature set. What I am talking about is adding the ability to intercept the event generated when a user selects a link in a webpage being displayed with a UIWebView, this will then allow you to perform any action that you want.
When would you use this I hear you say? Well one person asked me if I knew how to append the users current location onto all HTTP requests? and another just wanted to know how to perform custom actions from an embedded UIWebView.

Once again I will be extending the “Build your very own Web Browser!”, if you haven’t already completed it then I suggest that you head over there now and spend 5 minutes reading it and then downloading the project files at the end.
Start by opening up the WebBrowserTutorialAppDelegate.h file and editing the @interface line to read:

@interface WebBrowserTutorialAppDelegate : NSObject  {
 
What we have done is to make the main AppDelegate a delegate for the UIWebView as well.
Now we need to set our webView to have the main AppDelegate as its delegate, you can do this by opening up WebBrowserTutorialAppDelegate.m and putting the following line just inside theapplicationDidFinishLaunching function:

webView.delegate = self;

Installing GIT on OS-X In 3 Minutes

How to install GIT on OS-X in under 3 minutes:

curl http://kernel.org/pub/software/scm/git/git-1.7.1.tar.gz -O
tar xzvf git-1.7.1.tar.gz
cd git-1.7.1
make configure
./configure --prefix=/usr/local
NO_MSGFMT=yes make prefix=/usr/local all
sudo make install
 
Git should be installed on your OS-X now, which you can verify by issuing: git --version command in Terminal. However, it’s a good idea to also pre-configure the default username and e-mail for your Git installation:

git config --global user.name "Your Firstname Lastname"
git config --global user.email "username@example.com"
git config --global --list
 
I personally, also like to set:

git config --global color.ui "auto"

How to Setting up the GIT

Setting Up

Now that you have the pre-reqs all ready, you can proceed with the install.  Open a terminal and cd into the directory where you want to install things.  Then type the following (or just copy and paste the items below):

git clone git://github.com/sproutit/sproutcore-abbot.git abbot
cd abbot
rake init
cd ..
git clone git://github.com/sproutit/sproutcore-samples.git samples
cd samples
mkdir -p frameworks
cd frameworks
git clone git://github.com/sproutit/sproutcore.git sproutcore
cd ../..

Add the path to abbot/bin to the beginning of your PATH to be able run the abbot command-line tools (sc-init, sc-server, sc-build, sc-gen, sc-manifest, sc-docs, and more) without having to enter the full path:
export PATH=`pwd`/abbot/bin:$PATH
Make sure you have configured your github account with SSH Keys and Username/Email (Without setting up the SSH key for your machine, you will get a permission denied error when trying to initialize the Git repository)
You should now have the full set of SproutCore tools running the latest Abbot-compatible code.

How to Dismiss the Keyboard when using a UITextView

The short answer is to send the UITextViewController the “resignFirstResponder” message … the trick however is when to send the message. In my case, and I assume it would be the same for others, is to listen for any changes to the text in the UITextView and if the carridge return character ‘\n’ is detected then send the “resignFirstResponder” message to the UITextView.
Step 1. The first step is to make sure that you declare support for the UITextViewDelegate protocol. This is done in your header file, as example here is the header called EditorController.h:
@interface EditorController : UIViewController  {
  UITextView *messageTextView;
}
 
@property (nonatomic, retain) UITextView *messageTextView;
 
@end
Step 2. Next you will need to register the controller as the UITextView’s delegate. Continuing from the example above, here is how I have initialize the UITextView with EditorController as the delegate …
- (id) init {
    if (self = [super init]) {
        // define the area and location for the UITextView
        CGRect tfFrame = CGRectMake(10, 10, 300, 100);
        messageTextView = [[UITextView alloc] initWithFrame:tfFrame];
        // make sure that it is editable
        messageTextView.editable = YES;
 
        // add the controller as the delegate
        messageTextView.delegate = self;
    }
Step 3. And now the final piece of the puzzle is to take action in response to the “shouldCahngeTextInRange” message as follows:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range
  replacementText:(NSString *)text
{
    // Any new character added is passed in as the "text" parameter
    if ([text isEqualToString:@"\n"]) {
        // Be sure to test for equality using the "isEqualToString" message
        [textView resignFirstResponder];
 
        // Return FALSE so that the final '\n' character doesn't get added
        return FALSE;
    }
    // For any other character return TRUE so that the text gets added to the view
    return TRUE;
}

iPhone On-Screen Keyboard Rundown

As I started building the latest Consumetrics iPhone app over the weekend, I had to choose which keyboard style to use for some input fields like name, email, and so on. These fields live in a “settings table” (really just a grouped table with input fields on it), so picking keyboards in Interface Builder is out of the question, unfortunately, since I require some pretty customized cells. Naturally, I checked the documentation first, where I was confronted by this plethora of options:
typedef enum {
        UIKeyboardTypeDefault,
        UIKeyboardTypeASCIICapable,
        UIKeyboardTypeNumbersAndPunctuation,
        UIKeyboardTypeURL,
        UIKeyboardTypeNumberPad,
        UIKeyboardTypePhonePad,
        UIKeyboardTypeNamePhonePad,
        UIKeyboardTypeEmailAddress,
        UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable
    } UIKeyboardType;
Good grief. Seven distinct keyboard types? Bah. (Yes, 9 appear in the list, but UIKeyboardTypeDefault and UIKeyboardTypeAlphabet are just aliases for other types. Quiet you.) Some choices were obvious — my email address field will probably use UIKeyboardTypeEmailAddress, for instance — but some other choices are kind of head-scratchers. One of the fields wants a quantity, for example. Which keyboard should I use for that bad boy? UIKeyboardTypeNumberPad? But what if I need units, like “cups”? Can I get an alphabetic keyboard from UIKeyboardTypeNumberPad? I didn’t know, and tragically neither does Google; there aren’t any good breakdowns of iPhone keyboard types on the first few pages. Hitting up some blogs finally pointed me to some more Apple documentation, but even that still didn’t answer all my questions.
After not finding what I need, I did what any good developer would do: put down what I was supposed to be doing, and pick up something more interesting. I slapped together a quick iPhone app to display each keyboard type through a table view, the source for which is attached, and used it to scribble down a quick reference, which follows forthwith:
Overview

How to take Screenshot in Mac


In the article you’ll learn how to take screenshot in mac os. Although it’s very easy and quite interesting work but for the new users it’s bit confusing.
But anyways…to take the screenshots in mac os press “Command button +Shift+3″ and it’ll capture & save the image on desktop.
Apart from it there are many more interesting commands to take the screenshot, let’s see below…
1. To select the area and then take the screenshot give following command
“Command button +Shift+4″
2. Press “Command+Shift+4+space” if you wanted to take the screenshot of complete window.
Foregoing commands will save the screenshot at desktop. You can also save the screenshots in to clipboard. To do that you have to press one more button “Control” with the given commands. for example …
Use “Command+ control+ Shift+ 3″ instead of simple
“Command button +Shift+3″ command.
Apart from it mac os provide a software called “Grab” to capture the images in different styles. You can find this software in : Applications->utilities->Grab

How To Easily Share Files Between Mac & Windows Computers

File sharing between Macs and Windows is a little lob-sided. Out of the box, Macs can detect any Windows computer connected to the local network. It appears right on the Finder’s sidebar. So naturally, it is very easy for a Windows user to share their files with anyone on a Mac. The reverse process – allowing a Mac to share its files – requires a little more attention. The transition from Tiger to Leopard has made it a little bit more complicated for regular users to set up shared folders because the setting has been “disguised”.
In this week’s Macnifying OS X, I’m going to show you how easy it is to share files on your Mac so that it appears on Windows computers automatically.
how to share files between mac and pc

Adding a new user account to Mac

System Prefs Icon

Adding a new user account to your computer

You can create individual user accounts for each person who uses your computer. Each new user has a separate home folder and can adjust his or her own preferences without affecting other users.
  1. Choose Apple menu > System Preferences and click Accounts.
  2. If some settings are dimmed, click the lock icon and type an administrator name and password.
  3. Click Add (+) and type the user’s name.
  4. If you don’t want to use the short name generated automatically, type a new short name. (Once the account is created, you won’t be able to change the short name.)
  5. Type the user’s password in the Password and Verify boxes.
  6. Type a hint to help the user remember the password if they have trouble remembering it at login.
  7. Click Parental Controls and select options to determine what the user can do with the computer.
If you change your mind while you’re creating a new user account, click Delete (-) to cancel.

iphone/ipad force shutdown

iPhone 3G Force Shut-Down


I’ve had my iPhone 3G for a bit over 2 weeks now and am loving it!
But it is a bit glitchy at locking up (especially when the battery is low or you disconnect during a sync with iTunes)
If some does happen (such as the unlock screen not accepting your keystrokes to unlock it and you can’t for some reason power off just by holding the top button for a few seconds) then you either have to drain the battery
- lengthy and not great if as me you may have to do something such as get on a plane!
Or much more handily, use the force power down – like on any computer, iPod etc.
(The image shows a key being pressed, however this digit isn’t being recognised by the phone – this is when you may need to force quit)

What you do is press and hold the top right button (for locking/unlocking) and also the big button at the bottom of the screen – hold them down for between 5 – 10 seconds, and your phone will just switch off
Turn as normal and it should work!

iPhone SDK: Testing Network Reachability

Check Network Resources Before Use

reachability-alert

Using Facebook-connect for iPhone SDK to post stories to Facebook is a great feature to add to your iPhone application. But what happens if the user has no access to the network? If you don’t check the network, the answer is nothing. This leads to user confusion, and it will prevent your app from being approved for the App Store.
So, how do you check? Apple provided a sample application called Reachability which provides the answer. I’ll demonstrate here. In several blog posts people felt that the Reachability sample was overkill for their needs. If you agree, here’s a link to a recipe from The iPhone Developer’s Cookbook that provides an alternate solution. Even if you don’t plan on using it, I recommend reading through the code in the Reachability example.

Project Setup

In an earlier post I used the Facebook-Connect for iPhone SDK to post stories to Facebook. I’ll use the same project to demonstrate how to check that Facebook is reachable. Here’s the project with the API Keys and Template Bundle IDs removed. fbconnect-iphone.zip I’ll include a link to the final project at the end.
Download the Reachability project too. I’ll be importing a class from it to check the network connection status.

How to concatenate char / string on iPhone?

NSString *string = [NSString stringWithFormat:@"%@ %@", @"Hello", @"World"];
NSLog(@"%@", string);

or

NSString *string1 = @”Hello”;
NSString *string2 = @”World”;

string1 = [string1  stringByAppendingString:string2];

Capture iPhone Simulator Screenshots – Revisited – iPhone Simulator Cropper

iPhone project was looking for a tool to capture a series of screenshots for an upcoming application demo. In a Google search he first bumped into a post I wrote back in February of 2009: Capture iPhone Simulator Screenshots – Open Source Screen Capture Tool, a nice Mac tool for taking screenshots. As luck would have it, he also found another screen capture tool, one focused solely on iPhone screenshots: iPhone-Simulator Cropper.
iPhone-Simulator Cropper
This tool works by capturing the screen of the simulator runnning on your system. One really slick feature is the option to create captured images in two primary formats – first, a format suitable for upload to iTunes for your application screenshots – second, capturing a screenshot that is suitable for display on a website.
The following images show the iPhone-Simulator Cropper application, as well as two sample images captured:

iTunes Connect / App Store:

Website (iPhone Device from Apple Marketing):

2 Ways to Take Screenshots From Your iPhone

Ever wanted to know how to get great screenshots from your iPhone? It’s really easy. With the iPhone 2.0 software, you can simply hold down the Home button and press the top (on/off) button. The screen will flash and the screenshot will be saved to your iPhoto library. That’s quick and simple, for sure, but to actually use the screenshots on your computer you still have to transfer them.
You can also grab screenshots directly from your computer while plugged into your iPhone or iPod Touch. First, you have to download and install the iPhone SDK. Don’t worry, it’s free. You just have to have the desktop software tools that come with the SDK.

Open Xcode and open the Organizer window (from the Window menu). Plug in your iPhone or iPod Touch and in a few seconds, it should appear in the list of devices on the left. The first time you plug in your iPhone or iPod Touch you will be asked if you want to use that device for development.

Once you’ve got your device setup, just click the “Screenshot” tab in the Organizer window and you can capture screenshots from your device. You can capture literally any screenshot, including the lock screensaver, video as it’s playing, even as you’re holding a button down.