Wednesday 28 December 2011

Sort NSMutableArray according to Key



<array>
   <dict>
       name =  "zain"
   <dict/>
   <dict>
       name =  "fahad"
   <dict/>
   <dict>
   name =  "Aslam"
   <dict/>
    <dict>
   name =  "kashif"
   <dict/>
<array/>





-(NSMutableArray *)sortArrayAccordingTokey:(NSMutableArray *)array
{
    NSSortDescriptor *sortDescriptor;
    sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES] autorelease];
    NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
    NSArray *sortedArray = [array sortedArrayUsingDescriptors:sortDescriptors];
    [array removeAllObjects];
    [array addObjectsFromArray:sortedArray];
    return array;
}

Saturday 24 December 2011

iPhone Web Services - PHP


iPhone Web Services - IPhone to php to SQL  (Watch all parts)

http://www.youtube.com/watch?v=IQcLngIDf9k&feature=related

 

iPhone Web Services - JSON   (Watch all Parts)

http://www.youtube.com/watch?v=zU8RAeWO2NE&feature=related

Monday 19 December 2011

Convert NSString into NSDate and Compare two NSDates



NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"yyyy-MM-dd"];

 NSDate *date1 = [formatter dateFromString:@"2011-12-19"];
 NSDate *date2 = [formatter dateFromString:@"2011-12-15"];

NSComparisonResult result;
result = [date1 compare:date2];

if (result==NSOrderedAscending) {

NSLog(@"date2 is in the future");

} else if (result==NSOrderedDescending) {

NSLog(@"date2 is in the past");

} else {

NSLog(@"Both dates are the same");
}

Install Multiple Xcode versions


Message Errror:
"Scanning for plug-ins failed - You may not have appropriate permission to read or load installed plug-ins"

Solutions and Guide How to Install Multiple Versions:

http://useyourloaf.com/blog/2010/9/7/installing-multiple-xcode-versions.html

Tuesday 22 November 2011

Tuesday 15 November 2011

iPhone apps should include an armv6 architecture (issue)


Issue is resolve here:

http://stackoverflow.com/questions/4198676/warning-iphone-apps-should-include-an-armv6-architecture-even-with-build-config

Thursday 10 November 2011

iOS 5 SDK Tutorial And Ebook


iOS 5 SDK Tutorial And Guide Page:

http://maniacdev.com/ios-5-sdk-tutorial-and-guide/

http://osx.hyperjeff.net/Reference/CocoaArticles?cat=60

Ebook:

http://www.ebooks.ac/ebooks/ios-5-programming-cookbook-pdf/#more-1431

Thursday 3 November 2011

Paypal Integration in iPhone, android and Blackberry


Video:
http://www.ampev1.com/ondemands/Paypal/080510_PayPal/iphone_v10.htm

SDK:
https://www.x.com/developers/paypal/products/mobile-payment-libraries

Add text field and keyboard in scrollview in iphone


///////////// Keyboard //////////////////////




-(void) keyboardDidShow: (NSNotification *)notif {
   NSLog(@"Keyboard is visible");
   // If keyboard is visible, return
   if (keyboardVisible) {
       NSLog(@"Keyboard is already visible. Ignore notification.");
       return;
   }
 
   // Get the size of the keyboard.
   NSDictionary* info = [notif userInfo];
   NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
   CGSize keyboardSize = [aValue CGRectValue].size;
 
   // Save the current location so we can restore
   // when keyboard is dismissed
   offset = scrollview.contentOffset;
 
   // Resize the scroll view to make room for the keyboard
   CGRect viewFrame = scrollview.frame;
   viewFrame.size.height -= keyboardSize.height;
   scrollview.frame = viewFrame;
 
   CGRect textFieldRect = [activeField frame];
   textFieldRect.origin.y += 10;
   [scrollview scrollRectToVisible:textFieldRect animated:YES];
 
   NSLog(@"ao fim");
   // Keyboard is now visible
   keyboardVisible = YES;
}

-(void) keyboardDidHide: (NSNotification *)notif {
   // Is the keyboard already shown
   if (!keyboardVisible) {
       NSLog(@"Keyboard is already hidden. Ignore notification.");
       return;
   }
 
   // Reset the frame scroll view to its original value
   scrollview.frame = CGRectMake(0, 0, SCROLLVIEW_CONTENT_WIDTH, SCROLLVIEW_CONTENT_HEIGHT);
 
   // Reset the scrollview to previous location
   scrollview.contentOffset = offset;
 
   // Keyboard is no longer visible
   keyboardVisible = NO;
 
}

-(BOOL) textFieldShouldBeginEditing:(UITextField*)textField {
   activeField = textField;
   return YES;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
   [textField resignFirstResponder];
   return YES;
}

- (void)viewDidAppear:(BOOL)animated {

 
 
   NSLog(@"Registering for keyboard events");
 
   // Register for the events
   [[NSNotificationCenter defaultCenter]
    addObserver:self
    selector:@selector (keyboardDidShow:)
    name: UIKeyboardDidShowNotification
    object:nil];
   [[NSNotificationCenter defaultCenter]
    addObserver:self
    selector:@selector (keyboardDidHide:)
    name: UIKeyboardDidHideNotification
    object:nil];
 
   // Setup content size
   scrollview.contentSize = CGSizeMake(SCROLLVIEW_CONTENT_WIDTH,
                                       SCROLLVIEW_CONTENT_HEIGHT);
 
   //Initially the keyboard is hidden
   keyboardVisible = NO;
 
}

-(void) viewWillDisappear:(BOOL)animated {
   NSLog (@"Unregister for keyboard events");
   [[NSNotificationCenter defaultCenter]
    removeObserver:self];
}


//////////////////////////////////////////////


   IBOutlet UIScrollView *scrollview;
   BOOL keyboardVisible;
   CGPoint offset;
   UITextField *activeField;

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

and

@synthesis scrollview

#define SCROLLVIEW_CONTENT_HEIGHT 416
#define SCROLLVIEW_CONTENT_WIDTH  320



Friday 28 October 2011

Formatting of titleforHeaderInSection


- (UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section {
 UILabel *sectionHeader = [[[UILabel alloc] initWithFrame:CGRectNull] autorelease];
 sectionHeader.backgroundColor = [UIColor clearColor];
 sectionHeader.textAlignment = UITextAlignmentLeft;
 sectionHeader.font = [UIFont boldSystemFontOfSize:10];
 sectionHeader.textColor = [UIColor whiteColor];
 sectionHeader.text = [[plistArray objectAtIndex:section]objectForKey:@"Header"]; // <-- allows loading of sectionHeader text from a plist
 return sectionHeader;
}
- (CGFloat)tableView:(UITableView *)tableViewheightForHeaderInSection:(NSInteger)section {
 return 40;
} 

Thursday 27 October 2011

How to set the zoomlevel of MKMapView


    MKCoordinateRegion region;
    region.center=newLocation.coordinate;   // location
    MKCoordinateSpan span;
    span.latitudeDelta=120;               //  0.001 to 120
    span.longitudeDelta=120;
    region.span=span;
    [self.mapView setRegion:region animated:YES];   

Tuesday 4 October 2011

Add Custom delegate in iPhone

You will want to declare a delegate protocol for your class. An example of a delegate protocol and interface for class Foo might look like this:
 
 
@class Foo;
@protocol FooDelegate <NSObject>
@optional
- (BOOL)foo:(Foo *)foo willDoSomethingAnimated:(BOOL)flag;
- (void)foo:(Foo *)foo didDoSomethingAnimated:(BOOL)flag;
@end
@interface Foo : NSObject {
     NSString *bar;
     id <FooDelegate> delegate;
}
@property (nonatomic, retain) NSString *bar;
@property (nonatomic, assign) id <FooDelegate> delegate;
- (void)someAction;
@end
 
 
 
Don't forget to synthesize your properties in the @implementation.
 
 
How to USE: 
 
@interface SomeClass : SuperClass <FooDelegate> {} 
 
 
Foo *obj = [[Foo alloc] init];
[obj setDelegate:self];
 
 
 
Reference: 
http://stackoverflow.com/questions/645449/how-to-use-custom-delegates-in-objective-c 

Monday 3 October 2011

Gif Animations in iPhone


http://www.bigoo.ws/Images/flowers-gif/14-1-1109.htm


  UIImageView *imgView;
 @property (nonatomic, retain) IBOutlet UIImageView *imgView;
 @synthesize imgView;

  imgView.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"1.png"],[UIImage imageNamed:@"2.png"],[UIImage imageNamed:@"3.png"],[UIImage imageNamed:@"4.png"],nil];
    imgView.animationDuration = 3.5;
    imgView.animationRepeatCount = 0;
    [imgView startAnimating];





Friday 30 September 2011

Add New Contact in iPhone by Code


Add AddressBook Framework.

#import <AddressBook/AddressBook.h>


       ABRecordRef aRecord = ABPersonCreate();
       CFErrorRef  anError = NULL;
      
       ABRecordSetValue(aRecord,kABPersonOrganizationProperty,CFSTR("Sierra Tucson"), &anError);

       ABMutableMultiValueRef multiWebUrl = ABMultiValueCreateMutable(kABMultiStringPropertyType);
       ABMultiValueAddValueAndLabel(multiWebUrl, @"www.sierratucson.com", CFSTR("Web"), NULL);
       ABRecordSetValue(aRecord, kABPersonURLProperty, multiWebUrl, &anError);
       CFRelease(multiWebUrl);
      
      
       ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
       ABMultiValueAddValueAndLabel(multiPhone, @"8006245858", CFSTR("Phone"), NULL);
       ABMultiValueAddValueAndLabel(multiPhone, @"8006249001", CFSTR("Intake"), NULL);           
       ABRecordSetValue(aRecord, kABPersonPhoneProperty, multiPhone,nil);
      
      
       if (anError != NULL) {
          
           NSLog(@"error while creating..");
       }
      
       //ABAddressBookRef addressBook;
       CFErrorRef error = NULL;
       //addressBook = ABAddressBookCreate();
      
       BOOL isAdded = ABAddressBookAddRecord (addressBook,aRecord,&error);
      
       if(isAdded){
           NSLog(@"added..");
       }
       if (error != NULL) {
           NSLog(@"ABAddressBookAddRecord %@", error);
       }
       error = NULL;
      
       BOOL isSaved = ABAddressBookSave (addressBook,&error);
       if(isSaved)
       {
           NSLog(@"saved..");
       }
      
       if (error != NULL)
       {
           NSLog(@"ABAddressBookSave %@", error);
       }
      
       CFRelease(aRecord);
       CFRelease(multiPhone);
       CFRelease(addressBook);

Thursday 29 September 2011

RTSP Url Link of mekke and medina

rtsp://media2.kure.tv:1935/live/mekke1

rtsp://media2.kure.tv:1935/live/medine1

JavaScript use in UIwebview in iphone

http://blog.techno-barje.fr/post/2010/10/06/UIWebView-secrets-part3-How-to-properly-call-ObjectiveC-from-Javascript
http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview

Friday 23 September 2011

Html Parsing Using XPAth in iPhone


http://stackoverflow.com/questions/405749/parsing-html-on-the-iphone

code:  https://github.com/topfunky/hpple


XPath: http://www.w3schools.com/XPath/default.asp

Thursday 15 September 2011

iPhone – Local Notifications

http://www.icodeblog.com/2010/07/29/iphone-programming-tutorial-local-notifications/

http://useyourloaf.com/blog/2010/7/31/adding-local-notifications-with-ios-4.html

Using MPMusicPlayerController to Play an Existing Playlist

http://craigcoded.com/2011/01/11/using-mpmusicplayercontroller-to-play-an-existing-playlist/

Friday 26 August 2011

Simple AlertBox in Android


How to show AlertBox in Android:


    protected void alertbox(String title, String mymessage)
    {
    new AlertDialog.Builder(this)
       .setMessage(mymessage).setTitle(title).setCancelable(true)
       .setNeutralButton("OK",new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton){}
          })
       .show();
    }

Toast in Android


How to Show Toast in Android:

Toast.makeText(this, "You selected: " + mystr, Toast.LENGTH_LONG).show();

How to Dismiss Keyboard in Android

If you want to just dismiss it you can use the following lines of code in your button's on click Event.

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

Thursday 25 August 2011

Android: RadioButton Group


http://coderzheaven.com/2011/08/how-to-use-radiobuttongroup-in-android/

http://www.androidpeople.com/android-radiobutton-example

Android XML Parse using Document Builder

Android tutorial: How to parse/read XML data into Android ListView

http://p-xr.com/android-tutorial-how-to-parseread-xml-data-into-android-listview/

 

Wednesday 24 August 2011

Android List View

Good Tutorials

http://www.vogella.de/articles/AndroidListView/article.html

http://developer.android.com/resources/tutorials/views/hello-listview.html

http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/

http://android-helper.blogspot.com/2011/03/android-search-in-listview-example.html


List with TextEdit:


http://www.vogella.de/blog/2011/07/26/android-how-to-filter-a-listview-based-on-an-edittext-field/

http://android-helper.blogspot.com/2011/03/android-search-in-listview-example.html







Friday 19 August 2011

How to add CoverFlow in iPhone App


http://blog.objectgraph.com/index.php/2010/04/09/how-to-add-coverflow-effect-on-your-iphone-app-openflow/

http://iphoneized.com/2009/05/3d-coverflow-iphone-cssvfx/

iOS Projects Open Source Link (Source Code)


For new animations

http://code4app.net


http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-music-library-access/

http://www.roseindia.net/tutorial/iphone/examples/index.html

http://developer.apple.com/library/ios/navigation/#section=Resource%20Types&topic=Sample%20Code

http://appsamuck.com/

http://www.mobisoftinfotech.com/blog/iphone/iphone-open-source-applications/

http://visionwidget.com/toolz/4-design/509-open-source-iphone-apps-in-app-store.html

http://www.iphonecodesource.com/SourceCode.aspx

http://www.theiphonedev.com/SourceCode/tabid/143/Default.aspx

http://code.google.com/hosting/search?q=iphone&filter=0&start=490

https://masterbranch.com/prayer-book-project/263942

http://www.ifans.com/forums/showthread.php?t=147476

http://ntt.cc/2010/09/05/50-open-source-iphone-apps-for-iphone-developers.html
http://www.edumobile.org/iphone/iphone-programming-tutorials/25-amazing-open-source-iphone-apps/
http://stackoverflow.com/questions/1353130/where-can-i-find-sample-iphone-code


Games:

https://docs.google.com/spreadsheet/ccc?key=0Ap9yzw5RaZIZdFNoWEtvTXdfbThHM0hJUGxWUHZwSGc#gid=0


http://maniacdev.com/2010/06/35-open-source-iphone-app-store-apps-updated-with-10-new-apps/

http://ntt.cc/2010/09/05/50-open-source-iphone-apps-for-iphone-developers.html






Android Video Tutorials


Good Android Videos

http://www.youtube.com/watch?v=xtsyrKdPZVw&feature=related


Second Tutorials

http://www.youtube.com/watch?v=UC2wAuxECw0

App Icons on iPad and iPhone

 

Latest:

http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html 

 

App Icons on iPad and iPhone

http://developer.apple.com/library/ios/#qa/qa1686/_index.html 

 

This link is most help full  

http://www.idev101.com/code/User_Interface/sizes.html


Apple iphone Interface GuideLines

https://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html

https://developer.apple.com/library/ios/#DOCUMENTATION/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html

Tuesday 10 May 2011

Text Font Family



[label setFont:[UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:30]];

http://support.apple.com/kb/HT5484

http://iosfonts.com/




Family: Courier
Font: Courier
Font: Courier-BoldOblique
Font: Courier-Oblique
Font: Courier-Bold
Family: AppleGothic
Font: AppleGothic
Family: Arial
Font: ArialMT
Font: Arial-BoldMT
Font: Arial-BoldItalicMT
Font: Arial-ItalicMT
Family: STHeiti TC
Font: STHeitiTC-Light
Font: STHeitiTC-Medium
Family: Hiragino Kaku Gothic ****
Font: HiraKakuProN-W6
Font: HiraKakuProN-W3
Family: Courier New
Font: CourierNewPS-BoldMT
Font: CourierNewPS-ItalicMT
Font: CourierNewPS-BoldItalicMT
Font: CourierNewPSMT
Family: Zapfino
Font: Zapfino
Family: Arial Unicode MS
Font: ArialUnicodeMS
Family: STHeiti SC
Font: STHeitiSC-Medium
Font: STHeitiSC-Light
Family: American Typewriter
Font: AmericanTypewriter
Font: AmericanTypewriter-Bold
Family: Helvetica
Font: Helvetica-Oblique
Font: Helvetica-BoldOblique
Font: Helvetica
Font: Helvetica-Bold
Family: Marker Felt
Font: MarkerFelt-Thin
Family: Helvetica Neue
Font: HelveticaNeue
Font: HelveticaNeue-Bold
Family: DB LCD Temp
Font: DBLCDTempBlack
Family: Verdana
Font: Verdana-Bold
Font: Verdana-BoldItalic
Font: Verdana
Font: Verdana-Italic
Family: Times New Roman
Font: TimesNewRomanPSMT
Font: TimesNewRomanPS-BoldMT
Font: TimesNewRomanPS-BoldItalicMT
Font: TimesNewRomanPS-ItalicMT
Family: Georgia
Font: Georgia-Bold
Font: Georgia
Font: Georgia-BoldItalic
Font: Georgia-Italic
Family: STHeiti J
Font: STHeitiJ-Medium
Font: STHeitiJ-Light
Family: Arial Rounded MT Bold
Font: ArialRoundedMTBold
Family: Trebuchet MS
Font: TrebuchetMS-Italic
Font: TrebuchetMS
Font: Trebuchet-BoldItalic
Font: TrebuchetMS-Bold
Family: STHeiti K
Font: STHeitiK-Medium
Font: STHeitiK-Light

Tuesday 3 May 2011

Self-Signing


http://apple.stackexchange.com/questions/398/how-do-i-build-apps-to-my-jailbroken-ipad

http://oldhu.wordpress.com/2008/12/25/self-sign-an-iphone-app-to-debug-it-on-device/



Bundle Identifier = com.apple.platform.iphoneos

Thursday 28 April 2011

Change UISlider Image in Iphone


There are three images in UISlider you can change

1) left (default blue)
2) right (default white)
3) thumb (default white circle)


UIImage *sliderLeftTrackImage = [[UIImage imageNamed: @"SliderMin.png"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];

UIImage *sliderRightTrackImage = [[UIImage imageNamed: @"SliderMax.png"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];

1)
[mySlider setMinimumTrackImage: sliderLeftTrackImage forState: UIControlStateNormal];

2)
[mySlider setMaximumTrackImage: sliderRightTrackImage forState: UIControlStateNormal];

3)
[mySlider setThumbImage:[UIImage imageNamed:@"thumb_image.png"] forState:UIControlStateNormal];

Wednesday 27 April 2011

Use Google Analytics in iphone

Please see these links

1) http://code.google.com/mobile/analytics/docs/iphone/

2) http://www.icodeblog.com/2010/04/22/how-to-integrate-google-analytics-tracking-into-your-apps-in-7-minutes/

3) Sample code also available in this link
http://code.google.com/intl/fr/mobile/analytics/download.html#Google_Analytics_SDK_for_iOS

Sunday 24 April 2011

How to convert Seconds into minutes

for example

70 second = 1 minute and 10 second


double progress = ...... ;
int minutes = floor(progress/60);
int seconds = trunc(progress - minutes * 60);

Load Local html file using UIWebView

Ok here is the single line you need to load local html files :

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"01" ofType:@"html"]isDirectory:NO]]];


This line loads a html-file named '01.html' which has to be located in your project resources.

Saturday 23 April 2011

Reserved characters after percent-encoding

! %21
* %2A
' %27
( %28
) %29
; %3B
: %3A
@ %40
& %26
= %3D
+ %2B
$ %24
, %2C
/ %2F
? %3F
# %23
[ %5B
] %5D

Friday 22 April 2011

Split one string into different strings

NSString *str = @"011597464952,01521545545,454545474,454545444|Hello this is were the message is.";

NSArray *firstSplit = [str componentsSeparatedByString:@"|"];
NSAssert(firstSplit.count == 2, @"Oops! Parsed string had more than one |, no message or no numbers.");
NSString *msg = [firstSplit lastObject];
NSArray *numbers = [[firstSplit objectAtIndex:0] componentsSepratedByString:@","];

// print out the numbers (as strings)
for(NSString *currentNumberString in number) {
NSLog(@"Number: %@", currentNumberString);
}

Friday 15 April 2011

get Time from NSDate


NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterNoStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString* currentTime = [dateFormatter stringFromDate:[NSDate date]];
[dateFormatter release];


UITextField: how to dismiss the Keyboard and Number Pad Keyboard

There are two ways, second is the easy way.


1) define delegate and

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}



2)


-(void)touchesBegan: (NSSet *)touches withEvent:(UIEvent *)event
{
// do the following for all textfields in your current view
[self.txtfieldname resignFirstResponder];
// save the value of the textfield, ...
}

3) Dismiss textview    

Define Delegate

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
   
    if([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
   
    return YES;
}

Sunday 3 April 2011

Installing an Ad Hoc Distribution

What is Ad Hoc Distribution?

Ad Hoc Distribution allows you to try an application before it’s
available in the iTunes App Store. This is how we distribute iPhone
applications to beta customers.

These instructions assume you have a .zip file. You can also look at instructions for
.ipa files.

Developers, if you have any customers running Windows Vista, you’re better off distributing with an .ipa file, so that iTunes handles the unzipping. To create a .ipa, move your AppName.app directory into a new directory called Payload, then zip the Payload folder and change the file extension to .ipa.

What You’ll Need

Before beginning the installation process you’ll need:
  • The .zip file for the application
    (usually AppName.app.AdHoc.zip)
  • The .mobileprovision file for the application
    (usually Ad_Hoc_Distribution_Profile.mobileprovision)
  • Your Device: the iPhone or iPod Touch whose UDID you emailed us
    previously (Remember?)
  • The computer you normally sync with your Device
We usually send the .zip and .mobileprovision files to you via email.

Installing the Application - Windows XP


  1. If you have the .zip and .mobileprovision files in an email, save them to a convenient location, such as your Desktop.
  2. Drag-and-drop the .mobileprovision file onto LibraryApplications in iTunes. On the Mac,
    you can just drag it to the iTunes icon in your dock.
    Winxp-itunes-add-mobileprovision-profile
  3. Extract the .zip file. To do this, right-click the .zip file and select Extract All… . Step through the wizard and accept the defaults by clicking Next.

    WINDOWS VISTA USERS: The built-in “Extract All…” command
    corrupts the application so that it cannot be installed. You should
    try using a different zip program like WinZip or WinRar to extract the
    Zip file. Better yet, ask the application developer to send you the
    application as a .ipa file instead of a .zip file,
    then you don’t have to unzip it.
    Winxp-extract-all
  4. Find the .app folder (usually AppName.app).
    Winxp-app-folder
  5. Drag-and-drop the whole .app folder onto LibraryApplications in iTunes. On the Mac, you can just drag it onto the iTunes icon in the dock.
    Winxp-itunes-add-app
  6. Verify that the application shows up in LibraryApplications. Note that it will not have its normal icon.
    Winxp-itunes-library-applications
  7. In iTunes, select your Device under Devices, choose the Application tab, and make sure that the new application is checked.
    Winxp-itunes-devices-iphone-applications
  8. Sync your Device and try out the new app!

If you run into any trouble installing an app,

please email the application developer.


Friday 1 April 2011

Iphone project most common configuration problems


Please check your Configuration (Release / Debug) in Project Settings
It is damn shit that default is release mode …. but you compile in debug mode
or vice versa

means set your configuration (like Header search paths, other linker flag)
in both release and debug mode.

Thursday 24 March 2011

Pop Over Control on iPad

Real helpful tutorials !


http://mobiforge.com/designing/story/using-popoverview-ipad-app-development

http://www.matthewcasey.co.uk/2010/04/07/tutorial-introduction-to-pop-over-control-on-ipad-part-2/

http://www.jannisnikoy.nl/index.php/2010/04/ipad-tutorial-creating-a-popoverviewcontroller

Tuesday 22 March 2011

Converting iPhone xib to iPad xib?

When I first tried to upgrade from an existing Iphone App to an Ipad App I used: "Universal App"! The Main thing here is, that you have to create all your xib files manually.

I did then tried it with the other option "Using a Single Xcode Project to Build Two Applications" - where all the necessary XIB Files are translated to Ipad...


Using a Single Xcode Project to Build Two Applications

Maintaining a single Xcode project for both iPhone and iPad development simplifies the development process tremendously by allowing you to share code between two separate applications. The Project menu in Xcode includes a new Upgrade Current Target for iPad command that makes it easy to add a target for iPad devices to your existing iPhone project. To use this command, do the following:

Open the Xcode project for your existing iPhone application.
Select the target for your iPhone application.
Select Project > Upgrade Current Target for iPad and follow the prompts to create two device-specific applications.

Launching Other Apps within an iPhone Application

Yes it is possible to lunch other apps within an iPhone application, it can be done via URL technique .

Examples of some of the key applications that you can launch via URL are:

Launch Apple Mail
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://info@iphonedevelopertips.com"]];

Dial a Phone Number (iPhone Only)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];

Launch the SMS Application
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:55555"]];

Launching the AppStore
NSURL *appStoreUrl = [NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/
wa/viewSoftware?id=291586600&mt=8"];
[[UIApplication sharedApplication] openURL:appStoreUrl];

How to set navigation controller color

To set navigation controller color there’s a simple solution. Write below code in your view ‘View did load delegate’

Predefine color

self.navigationController.navigationBar.tintColor = [UIColor redColor];

RGB color

self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:255/255 green:60/255 blue:0/255 alpha:100/255];

How to change the name of an iPhone app xcode

Just follow below three steps and you will be able to do it surely.

1. Select the target icon in your xCode
2. “Get Info” on your project’s target (your current old development name)
3. Search for “Product Name” under “Packaging”. Change the value of that what you want the new project name is going to be.

How to add ASIHTTPRequest in Iphone project

I faced some difficulties for how to use this great framework but then I find the official documentation link which is very helpful and solve my all problems.


http://allseeing-i.com/ASIHTTPRequest/Setup-instructions

How to convert Image into NSData

Here’s the simple solution.

NSData* topImageData = UIImageJPEGRepresentation(topImage, 1.0);

How to convert NSData into image

Here’s the simple code

UIImage *img = [[UIImage alloc] initWithData:data];

How to add button in UINavigationController

You can write following code in ViewDidLoad method

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(newDate:)];

and also define the selector to get the user interaction response

This is the Selector of above right bar button

- (void) newDate: (id) sender{
}

Float in objective c

Most people facing problem in how to control the numbers after point in objective c you can use the following trick in order to achieve this

NSString *floatMin = [NSString stringWithFormat:@"%.01f",anyFloatVariable];

In this way you can only get two decimals after point

CSV parser for iPhone

You can download the CSV parser from the following link

http://zeeshanullah.com/blog/downloads/CSV.zip

I’ve used this CSV parser in 3 of my applications and all are on iTunes so do not worry while using this.

Use code:

CSVParser *parser = [CSVParser new];
[parser openFile: filePath];
NSMutableArray *csvContent = [parser parseFile];

Simple is that create the new object of CSVParser then define the path and at last call parseFile method that will return NSMutableArray of csv file.

Text to Pdf for iPhone

I’ve made a function that creates pdf file from text.

void CreatePDFFile (CGRect pageRect, const char *filename) {

// This code block sets up our PDF Context so that we can draw to it
CGContextRef pdfContext;
CFStringRef path;
CFURLRef url;
CFMutableDictionaryRef myDictionary = NULL;
// Create a CFString from the filename we provide to this method when we call it

//********************************************************************************************************
//This is the path where pdf saved you can save it any where like inside iPhone in NSDATA and then mail it.
//********************************************************************************************************
path = CFStringCreateWithCString (NULL, filename,
kCFStringEncodingUTF8);

// Create a CFURL using the CFString we just defined
url = CFURLCreateWithFileSystemPath (NULL, path,
kCFURLPOSIXPathStyle, 0);
CFRelease (path);
// This dictionary contains extra options mostly for ‘signing’ the PDF
myDictionary = CFDictionaryCreateMutable(NULL, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(myDictionary, kCGPDFContextTitle, CFSTR(“My PDF File”));
CFDictionarySetValue(myDictionary, kCGPDFContextCreator, CFSTR(“My Name”));
// Create our PDF Context with the CFURL, the CGRect we provide, and the above defined dictionary
pdfContext = CGPDFContextCreateWithURL (url, &pageRect, myDictionary);
// Cleanup our mess
CFRelease(myDictionary);
CFRelease(url);
// Done creating our PDF Context, now it’s time to draw to it

// Starts our first page
CGContextBeginPage (pdfContext, &pageRect);

// Draws a black rectangle around the page inset by 50 on all sides
CGContextStrokeRect(pdfContext, CGRectMake(50, 50, pageRect.size.width – 100, pageRect.size.height – 100));

// This code block will create an image that we then draw to the page
const char *picture = “Picture”;
CGImageRef image;
CGDataProviderRef provider;
CFStringRef picturePath;
CFURLRef pictureURL;

picturePath = CFStringCreateWithCString (NULL, picture,
kCFStringEncodingUTF8);
pictureURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), picturePath, CFSTR(“png”), NULL);
CFRelease(picturePath);
provider = CGDataProviderCreateWithURL (pictureURL);
CFRelease (pictureURL);
image = CGImageCreateWithPNGDataProvider (provider, NULL, true, kCGRenderingIntentDefault);
CGDataProviderRelease (provider);
CGContextDrawImage (pdfContext, CGRectMake(200, 200, 207, 385),image);
CGImageRelease (image);
// End image code

// Adding some text on top of the image we just added
CGContextSelectFont (pdfContext, “Helvetica”, 16, kCGEncodingMacRoman);
CGContextSetTextDrawingMode (pdfContext, kCGTextFill);
CGContextSetRGBFillColor (pdfContext, 0, 0, 0, 1);
const char *text = “Yes I can Make PDF From Text”;
CGContextShowTextAtPoint (pdfContext, 260, 390, text, strlen(text));
// End text

// We are done drawing to this page, let’s end it
// We could add as many pages as we wanted using CGContextBeginPage/CGContextEndPage
CGContextEndPage (pdfContext);

// We are done with our context now, so we release it
CGContextRelease (pdfContext);
}

Below code to use this function.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *saveDirectory = [paths objectAtIndex:0];
NSString *saveFileName = @”myPDF.pdf”;
NSString *newFilePath = [saveDirectory stringByAppendingPathComponent:saveFileName];
const char *filename = [newFilePath UTF8String];
CreatePDFFile(CGRectMake(0, 0, 612, 792),filename);

That’s it……

Extract zip in iPhone

Below is the download link to unzip file within iPhone

http://zeeshanullah.com/blog/downloads/Zip.zip

Below is the code to use this zip library

ZipArchive *za = [[ZipArchive alloc] init];
if ([za UnzipOpenFile: fromFile]) {
BOOL ret = [za UnzipFileTo: toFile overWrite: YES];
if (NO == ret){} [za UnzipCloseFile];
}
[za release];

(fromFile : The zip file path)
(toFile : Where to place extracted zip)

UIColor from RGB iPhone

I’ve write the simple code.

#define UIColorFromRGB(rgbValue) \
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 \
alpha:1.0]

Use it like that
self.navigationController.navigationBar.tintColor = UIColorFromRGB(0xa90606);

Note:- write 0x before your RGB code.

Monday 21 March 2011

Asynchronous Loading of Images in a UITableView

http://kosmaczewski.net/2009/03/08/asynchronous-loading-of-images-in-a-uitableview/

How to use JSON in Objective-C

Learn JSON

http://www.json.org/

Use In Objective C

http://iphone.zcentric.com/2008/08/05/first-json-iphone-application/
http://blog.zachwaugh.com/post/309924609/how-to-use-json-in-cocoaobjective-c

Good Tutorial

http://blog.grio.com/2009/04/dealing-with-json-on-iphone.html

Monday 14 March 2011

How to compare date string with current date

- (NSString *)dateDifferenceStringFromString:(NSString *)dateString withFormat:(NSString *)dateFormat;
{

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setDateFormat:dateFormat];
NSDate *date = [dateFormatter dateFromString:dateString];
[dateFormatter release];
NSDate *now = [NSDate date];
double time = [date timeIntervalSinceDate:now];
time *= -1;
if(time < 1) {
return dateString;
} else if (time < 60) {
return @"less than a minute ago";
} else if (time < 3600) {
int diff = round(time / 60);
if (diff == 1)
return [NSString stringWithFormat:@"1 minute ago", diff];
return [NSString stringWithFormat:@"%d minutes ago", diff];
} else if (time < 86400) {
int diff = round(time / 60 / 60);
if (diff == 1)
return [NSString stringWithFormat:@"1 hour ago", diff];
return [NSString stringWithFormat:@"%d hours ago", diff];
} else if (time < 604800) {
int diff = round(time / 60 / 60 / 24);
if (diff == 1)
return [NSString stringWithFormat:@"yesterday", diff];
if (diff == 7)
return [NSString stringWithFormat:@"last week", diff];
return[NSString stringWithFormat:@"%d days ago", diff];
} else {
int diff = round(time / 60 / 60 / 24 / 7);
if (diff == 1)
return [NSString stringWithFormat:@"last week", diff];
return [NSString stringWithFormat:@"%d weeks ago", diff];
}
}

How to get Current date in iphone

NSDate* date = [NSDate date];
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss zzz"];
NSString* currentdate = [formatter stringFromDate:date];
NSLog(@"%@",currentdate);

Saturday 12 March 2011

Clear Webview in Viewwilldissapear

- (void) viewWillDisappear:(BOOL)animated{

[webView loadHTMLString:@"" baseURL:nil];
}

Friday 11 March 2011

how to remove white spaces from a string in objective C


A one line solution:

NSString *whitespaceString = @" String with whitespaces ";

NSString *trimmedString = [whitespaceString stringByReplacingOccurrencesOfString:@" " withString:@""];

Simple UIAlertView Use in IPhone

Define Delegate

UIAlertViewDelegate

then

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title" message:@"message?"
delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
[alert show];
[alert release];

and

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex (NSInteger)buttonIndex
{
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 0)
{
NSLog(@"NO");
}
else
{
NSLog(@"YES");
}
}

How to link to Google Map directions from iPhone app by address

NSString* urlString = @"http://maps.google.com/maps?saddr=London+UK&daddr=Birmingham+UK";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: urlString]];

iphone google maps - direction using latitude and longitude

NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude,
destLocation.coordinate.latitude, destLocation.coordinate.longitude];

[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];


How to make a phone call through programming in iPhone