Sunday 17 February 2013

not get iPhone simulator option on xcode? see this bellow answer

Some time you not seen the iPhone simulator option on xcode and just see the "Mac 64-bit" option.

so for get iPhone simulator option on xcode just change base SDK in project -> Build Setting and just set  "latest ios sdk" option instead of other.

Also see this bellow link with some other answers :

xcode-ios-project-only-shows-my-mac-64-bit-but-not-simulator-or-device

Friday 1 February 2013

How To change day like calendar's next prev button..


#pragma mark view calnder Next Prev

-(IBAction)btnRigth_Clicked:(id)sender{
    NSLog(@"\n Right Button Clicked");
    [self NextDate:lblTitleDate.text];
}

-(IBAction)btnLeft_Clicked:(id)sender{
    NSLog(@"\n Left Button Clicked");
    [self PrevDate:lblTitleDate.text];
}

-(void)NextDate:(NSString *)strDate{
    
    NSDate *selectedDate = [[NSDate alloc]init];
    selectedDate = [self convertStringToDate:strDate];
    
    // start by retrieving day, weekday, month and year components for yourDate
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *todayComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:selectedDate];
    NSInteger theDay = [todayComponents day];
    NSInteger theMonth = [todayComponents month];
    NSInteger theYear = [todayComponents year];
    
    // now build a NSDate object for yourDate using these components
    NSDateComponents *components = [[NSDateComponents alloc] init];
    [components setDay:theDay]; 
    [components setMonth:theMonth]; 
    [components setYear:theYear];
    NSDate *thisDate = [gregorian dateFromComponents:components];
    [components release];
    
    // now build a NSDate object for the next day
    NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
    [offsetComponents setDay:1];
    NSDate *nextDate = [gregorian dateByAddingComponents:offsetComponents toDate:thisDate options:0];
    [offsetComponents release];
    [gregorian release];
    lblTitleDate.text = [self convertDateToString:nextDate];
}

-(void)PrevDate:(NSString *)strDate{
    
    NSDate *selectedDate = [[NSDate alloc]init];
    selectedDate = [self convertStringToDate:strDate];
    // start by retrieving day, weekday, month and year components for yourDate
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *todayComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:selectedDate];
    NSInteger theDay = [todayComponents day];
    NSInteger theMonth = [todayComponents month];
    NSInteger theYear = [todayComponents year];
    
    // now build a NSDate object for yourDate using these components
    NSDateComponents *components = [[NSDateComponents alloc] init];
    [components setDay:theDay]; 
    [components setMonth:theMonth]; 
    [components setYear:theYear];
    NSDate *thisDate = [gregorian dateFromComponents:components];
    [components release];
    
    // now build a NSDate object for the next day
    NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
    [offsetComponents setDay:-1];
    NSDate *prevDate = [gregorian dateByAddingComponents:offsetComponents toDate:thisDate options:0];
    [offsetComponents release];
    [gregorian release];
    lblTitleDate.text = [self convertDateToString:prevDate];
}

-(NSDate *)convertStringToDate:(NSString *) date {
    NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease]; 
    NSDate *nowDate = [[[NSDate alloc] init] autorelease];
    [formatter setDateFormat:@"EEEE, dd MMM yyyy"];// set format here which format in string date
    date = [date stringByReplacingOccurrencesOfString:@"+0000" withString:@""];
    nowDate = [formatter dateFromString:date];
    // NSLog(@"date============================>>>>>>>>>>>>>>> : %@", nowDate);
    return nowDate;
}

-(NSString *)convertDateToString:(NSDate *) date {
    NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease]; 
    NSString *nowDate = [[[NSString alloc] init] autorelease];
    [formatter setDateFormat:@"EEEE, dd MMM yyyy"];// set format here which format in string date
    
    nowDate = [formatter stringFromDate:date];
    // NSLog(@"date============================>>>>>>>>>>>>>>> : %@", nowDate);
    return nowDate;
}