Search Results

Search found 30 results on 2 pages for 'nscalendar'.

Page 2/2 | < Previous Page | 1 2 

  • Cannot figure out how to get rid of memory leak

    - by Mark S.
    I'm trying to test for memory leaks in my iphone and I'm not having much luck getting rid of this one. Here is the code that is leaking. - (id)initWithManagedObjectContext:(NSManagedObjectContext *)aMoc delegate:(id)aDelegate runSync:(BOOL)aRunSync { if (self = [super init]) { self.moc = aMoc; self.settingsManager = [[VacaCalcSettingsManager alloc] initWithManagedObjectContext:self.moc]; self.delegate = aDelegate; calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; self.runSync = aRunSync; } return self; } It is leaking on the self.settingsManager = [[VacaCalcSettingsManager alloc] initWithManagedObjectContext:self.moc]; line. The self.settingManager instance variable is released in the dealloc method of the class. I'm not sure what other information would be pertinent. Please let me know and I can provide it. Thanks for any assistance. -Mark

    Read the article

  • Easiest way to get an NSDate representation of "the next 7am that will occur" in Cocoa?

    - by Drarok
    I figure I can achieve what I want by using NSCalendar and NSDateComponents, but that would run something like the following: Get "now" Create an NSDateComponents from "now". If "now" is pre-7am, then use today's date. If "now" is post-7am, use tomorrow's date. If today is the last day of the month, increase month, set day to 1. If it was December, increase year by 1 also. Set hour, minute, second. Create a new NSDate. It all seems very long-winded, but that appears to be what other answers on here suggest, and the documentation doesn't offer any clues. I'm going back and forth between all the date and calendar classes I can find. Is there a simple way to ask for the "next occurring 7am" ? Thanks.

    Read the article

  • Picker view wont rotate- iPhone

    - by lotuseater
    hi, I am making a booking page. I have included 3 pickers in it. I have included all the delegates required for the pickers to work but it wont rotate. I have enabled user interaction and multitouch in the nib file. Here is my code. Please help me. :( @interface ChooseContactsFrom : UIViewController { IBOutlet UIPickerView *statePickup; IBOutlet UIPickerView *paymentMethodPickup; IBOutlet UIDatePicker *expiryDatePickup; IBOutlet UIView *statePickupView; IBOutlet UIView *paymentMethodPickupView; IBOutlet UIView *expiryDatePickupView; } (void)viewDidLoad { self.title = @"Choose Contacts"; //Fill in the states name/ stateArray = [[NSArray alloc]initWithObjects:@"",nil]; paymentModeArray = [[NSArray alloc] initWithObjects:@"Credit Card", @"Cash",@"Account",@"Voucher",@"Debit Card", nil]; paymentMethodPickup.frame = CGRectMake(0.0, 44.0, paymentMethodPickup.frame.size.width, paymentMethodPickup.frame.size.height); paymentMethodPickup.userInteractionEnabled = YES; paymentMethodPickup.multipleTouchEnabled = YES; paymentMethodPickupView.frame = CGRectMake(0.0, 210.0, paymentMethodPickupView.frame.size.width, paymentMethodPickupView.frame.size.height); statePickup.frame = CGRectMake(0.0, 44.0,statePickup.frame.size.width, statePickup.frame.size.height); statePickupView.frame = CGRectMake(0.0, 210.0, statePickupView.frame.size.width, statePickupView.frame.size.height); stateArray = [[NSArray alloc] initWithObjects:@"state1", @"state2", @"state3", @"state4", @"state5", @"state6", @"state7", @"state8", @"state9", @"state10", nil]; expiryDatePickup.frame = CGRectMake(0.0, 44.0, expiryDatePickup.frame.size.width, expiryDatePickup.frame.size.height); expiryDatePickupView.frame = CGRectMake(0.0, 210.0, expiryDatePickupView.frame.size.width, expiryDatePickupView.frame.size.height); [super viewDidLoad]; } -(IBAction)back:(id)sender { [self dismissModalViewControllerAnimated:YES]; } pragma mark pickerView delegates (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { return 1; } (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { if( thePickerView == statePickup) { return [stateArray count]; } else if(thePickerView == paymentMethodPickup) { return [paymentModeArray count]; } else { return 0; } } (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { if(thePickerView == statePickup) { return [stateArray objectAtIndex:row]; } else if(thePickerView == paymentMethodPickup) { return [paymentModeArray objectAtIndex:row]; } else { return @" "; } } (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component{ return 50; } (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component { return 250; } (void)pickerView:(UIPickerView *)thepickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { if(thepickerView == statePickup) { state.text=[stateArray objectAtIndex:row]; } if(thepickerView == paymentMethodPickup) { payment.text=[paymentModeArray objectAtIndex:row]; } } (void)ClearSubviews { //[firstName resignFirstResponder]; // [lastName resignFirstResponder]; // [email resignFirstResponder]; // [address1 resignFirstResponder]; // [address2 resignFirstResponder]; // [city resignFirstResponder]; // //[state resignFirstResponder]; // [payment resignFirstResponder]; // [creditCard resignFirstResponder]; // [expirydate removeFromSuperview]; // [statePickup removeFromSuperview]; // [paymentMethodPickup removeFromSuperview]; } (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { // [self showPicker:textField]; //[self setViewMovedUp]; if(textField == firstName || textField == lastName || textField == email || textField == address1 || textField == address2 ||textField == city) { [self ClearSubviews]; //pickerToolbar.hidden = TRUE; return YES; } else if(textField == payment) { [self ClearSubviews]; [self setViewMovedUp]; [payment setText:[paymentModeArray objectAtIndex:0]]; [self.view insertSubview:paymentMethodPickupView aboveSubview:self.view]; return NO; } else if(textField == state) { [self ClearSubviews]; [self setViewMovedUp]; [state setText:[stateArray objectAtIndex:0]]; [self.view insertSubview:statePickupView aboveSubview:self.view]; return NO; } else if(textField == expirydate) { [self setViewMovedUp]; expiryDatePickup.date = [NSDate date]; NSDate *date1 = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateStyle:NSDateFormatterMediumStyle]; NSString *strDate=[dateFormatter stringFromDate:date1]; NSString *str=[[NSString alloc] initWithString: strDate]; [expirydate setText:str]; [self.view insertSubview:expiryDatePickupView aboveSubview:self.view]; return NO; } else if(textField == creditCard) { [self ClearSubviews]; [self setViewMovedUp]; return YES; } else { [self ClearSubviews]; return YES; } } -(BOOL)textFieldShouldEndEditing:(UITextField *)textField { return YES; } (void)textFieldDidEndEditing:(UITextField *)textField { if(textField == creditCard) { [self moveDown]; } } (BOOL)textFieldShouldReturn:(UITextField *)textField { [firstName resignFirstResponder]; [lastName resignFirstResponder]; [email resignFirstResponder]; [address1 resignFirstResponder]; [address2 resignFirstResponder]; [city resignFirstResponder]; [creditCard resignFirstResponder]; return YES; } -(IBAction)textFieldDoneEditing:(id)sender { [sender resignFirstResponder]; } ////////----------------------------------------------------------------------- pragma mark move screen (void)setViewMovedUp { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.3]; // Make changes to the view's frame inside the animation block. They will be animated instead // of taking place immediately. CGRect rect = [self.view frame]; // If moving up, not only decrease the origin but increase the height so the view // covers the entire screen behind the keyboard. rect.origin.y -= 50.0f; rect.size.height -= 80.0f; [self.view setFrame:rect]; [UIView commitAnimations]; } -(void)moveDown { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.3]; // Make changes to the view's frame inside the animation block. They will be animated instead // of taking place immediately. CGRect rect = [self.view frame]; rect.origin.y += 50.0f; rect.size.height += 80.0f; [self.view setFrame:rect]; // [UIView setBackgroundColor:[UIColor darkGrayColor]]; [UIView commitAnimations]; } pragma mark Method to show pickers -(void)showPicker:(UITextField *)textField { if(textField == expirydate) { expiryDatePickup .date = [NSDate date]; NSDate *date1 = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateStyle:NSDateFormatterMediumStyle]; NSString *strDate=[dateFormatter stringFromDate:date1]; NSString *str=[[NSString alloc] initWithString: strDate]; [expirydate setText:str]; [self.view insertSubview:expiryDatePickup aboveSubview:self.view]; } else if(textField == payment) { [payment setText:[paymentModeArray objectAtIndex:0]]; [self.view insertSubview:paymentMethodPickupView aboveSubview:self.view]; } else if(textField == state) { [state setText:[stateArray objectAtIndex:0]]; [self.view insertSubview:statePickupView aboveSubview:self.view]; } } (IBAction)datePickerChanged:(id)sender { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateStyle:NSDateFormatterMediumStyle]; NSDate *date=expiryDatePickup.date; formattedDateString1 = [dateFormatter stringFromDate:date]; [expirydate setText:formattedDateString1]; NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; unsigned int unitFlags = NSMonthCalendarUnit | NSDayCalendarUnit; components = [gregorian components:unitFlags fromDate:date]; [gregorian release]; } pragma mark done and cancel methods -(IBAction) btnCancelExpiryDate:(id)sender { [self moveDown]; [expirydate setText:@" "]; [expiryDatePickupView removeFromSuperview]; } -(IBAction) btnDoneExpiryDate:(id)sender { [self moveDown]; [expiryDatePickupView removeFromSuperview]; expiryDatePickup .date = [NSDate date]; } -(IBAction)cancelPaymentType:(id)sender { [self moveDown]; [payment setText:@" "]; [paymentMethodPickupView removeFromSuperview]; } -(IBAction)donePaymentType:(id)sender { [self moveDown]; [paymentMethodPickupView removeFromSuperview]; } -(IBAction)doneState:(id)sender { [self moveDown]; [statePickupView removeFromSuperview]; } (IBAction)cancelState:(id)sender; { [self moveDown]; [state setText:@" "]; [statePickupView removeFromSuperview]; }

    Read the article

  • Find Exact difference between two dates

    - by iPhone Fun
    Hi all , I want some changes in the date comparison. In my application I am comparing two dates and getting difference as number of Days, but if there is only one day difference the system shows me 0 as a difference of days. I do use following code NSDateFormatter *date_formater=[[NSDateFormatter alloc]init]; [date_formater setDateFormat:@"MMM dd,YYYY"]; NSString *now=[NSString stringWithFormat:@"%@",[date_formater stringFromDate:[NSDate date]]]; LblTodayDate.text = [NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@",now]]; NSDate *dateofevent = [[NSUserDefaults standardUserDefaults] valueForKey:@"CeremonyDate_"]; NSDate *endDate =dateofevent; NSDate *startDate = [NSDate date]; gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; unsigned int unitFlags = NSDayCalendarUnit; NSDateComponents *components = [gregorian components:unitFlags fromDate:startDate toDate:endDate options:0]; int days = [components day]; I found some solutions that If we make the time as 00:00:00 for comparision then it will show me proper answer , I am right or wrong i don't know. Please help me to solve the issue

    Read the article

  • Making alarm clock with NSTimer

    - by Alex G
    I just went through trying to make an alarm clock app with local notifications but that didn't do the trick because I needed an alert to appear instead of it going into notification centre in iOS 5+ So far I've been struggling greatly with nstimer and its functions so I was wondering if anyone could help out. I want when the user selects a time (through UIDatePicker, only time) for an alert to be displayed at exactly this time. I have figured out how to get the time from UIDatePicker but I do not know how to properly set the firing function of nstimer. This is what I have attempted so far, if anyone could help... be much appreciated. Thank you Example (it keeps going into the function every second opposed to a certain time I told it too... not what I want): NSDate *timestamp; NSDateComponents *comps = [[[NSDateComponents alloc] init] autorelease]; [comps setHour:2]; [comps setMinute:8]; timestamp = [[NSCalendar currentCalendar] dateFromComponents:comps]; NSTimer *f = [[NSTimer alloc] initWithFireDate:timestamp interval:0 target:self selector:@selector(test) userInfo:nil repeats:YES]; NSRunLoop *runner = [NSRunLoop currentRunLoop]; [runner addTimer:f forMode: NSDefaultRunLoopMode];

    Read the article

< Previous Page | 1 2