Delegate vs Notification in iOS

Both terminology provide a way by which iOS object communication to each other in iOS application Delegate faster creates a has-a relationship between the two classes Good architecure, You gain compile time checking for required methods when you use  protocols with your delegates, so you know when you compile if you're missing any required methods... Continue Reading →


Common method in Swift

1. Check for any field empty in NSDictionary class func checkforEmptyValueinDictioanty(dic:NSDictionary)-> Bool{ for (keyVal, dataVal) in dic {   if (dataVal.length()==0){                 println("\(keyVal): \(dataVal.length())")                 return false             }                 ... Continue Reading →

Use different font text in a Label in swift

let secondLabel=UILabel(frame: CGRectMake(0, 16, _screenWidth-2, 20))         secondLabel.textColor=UIColor.whiteColor()         secondLabel.textAlignment=NSTextAlignment.Center         secondLabel.font=UIFont(name: "Arial", size: 12)         bottomView.addSubview(secondLabel)                  let attrSting=NSMutableAttributedString(string: "I agree to the Terms of Service and Privacy Policy.")             ... Continue Reading →

How to call a function using NSNotification on custom Event.

Step 1. In viewDidLoad   // add notification- (void)viewDidLoad{    [super viewDidLoad];        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MoveToNextView:) name:@"SomeNotificationName" object:nil];    // Do any additional setup after loading the view, typically from a nib.}Step 2:  call Notification function-(IBAction)SendMessege:(id)sender{      [[NSNotificationCenter defaultCenter] postNotificationName:@"SomeNotificationName" object:nil];}step 3.-(IBAction)MoveToNextView:(id)sender{    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Notification Alert" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"ok", nil];    [alert show];} 

How to call a function When iOS application enter in background

write code below to call a function when application enter in background [[NSNotificationCenter defaultCenter] addObserver: self                                             selector: @selector(SendMessege:)                                                  name: UIApplicationDidEnterBackgroundNotification                                               object: nil];Where    SendMessege:  is a name of method to be calling.

Blog at

Up ↑

%d bloggers like this: