Friday, March 18, 2011

Use of Protocols to create and work on own delegates

Delegates are very useful to control transfer within the array of view controllers in app manually. Using delegates you can manage the control flow very well.

here is small example of own delegates....

1. Create a protocol class.... (.h only)



SampleDelegate.h


#import


@protocol SampleDelegate
@optional

#pragma Home Delegate

-(NSString *)getViewName;

@end



2. Import above protocol class in the class whom you want to make delegate of another class. Here in my ex. I m using AppDelegate to make delegate of The HomeViewController's Object.

also add above DelegateName in Delegate Reference < >


ownDelegateAppDelegate.h

#import "SampleDelegate.h"

@interface ownDelegateAppDelegate : NSObject <UIApplicationDelegate, SampleDelegate> {

}


ownDelegateAppDelegate.m

//setDelegate of the HomeViewController's object as
[homeViewControllerObject setDelegate:self];

//add this delegate method definition
-(NSString *)getViewName
{
    return @"Delegate Called";
}




HomeViewController.h

#import
#import "SampleDelegate.h"

@interface HomeViewController : UIViewController {
    
    id<SampleDelegate>delegate;
}

@property(readwrite , assign) id<SampleDelegate>delegate;

@end



HomeViewController.h

- (void)viewDidAppear:(BOOL)animated {
    
    [super viewDidAppear:animated];
    
    
    UILabel *lblTitle = [[UILabel alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    lblTitle.text = [delegate getViewName];
    lblTitle.textAlignment = UITextAlignmentCenter;
    [self.view addSubview:lblTitle];
}


 or download above source code from here.



Thursday, March 10, 2011

Update your MAC Softwares


Hey guys its time to update your MACs….. Update it with all new... 




1.Mac OS X v10.6.6 Update Combo

To download click here





3. xCode 4 (new with some great modifications, please note you have to pay $4.99 for that and if you have $99 account then its FREE for YOU.)

To download click here



3. iOS SDK 4.3

To download click here



4. iTunes 10.2.1

To download click here




4. iOS 4.3 Software Update


To download click here





5. Safari 5.0.4

To download click here


Happy Coding...!!! :)

Vivek Sharma
Bangalore, India