Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
545
Memory issue with datasource
posted

Hello,
I have a problem to set the datasource of the calendar.
I have a viewcontroller, in viewDidLoad I add calendar with addSubview.
In my viewcontroller I have an array of events (property)
I want to implement the method
-(NSArray*)calendarView:(IGCalendarView *)calView appointmentsForStart:(NSDate*)start end:(NSDate*)end ofType:(IGCalendarAppointmentRequestType)requestType 
in my view controller

then assign a datasource so
        calendar.appointmentDataSources = @[self]; 
appointments are not displayed.

So I created an ivar (NSArray) and I put self (my viewcontroller) in


source = @[self];

calendar.appointmentDataSources = @[self];


appointments are displayed, but the viewcontroller is never unloaded from memory, the dealloc method is not called


How can I successfully implement the datasource?
thanks

Parents
  • 40030
    Verified Answer
    Offline posted

    Hi!

    The memory leak is b/c you're storing a reference to self, on yourself. 

    You have 2 options. 

    1. Create an object that implements the datasource protocol for you, instead of implementing it on yourslf

    2. When you ViewController is going to disappear, you can remove the reference to yourself: 

    -(void)viewDidDisappear:(BOOL)animated

    {

        [super viewDidDisappear:animated];

       source = nil;

    }

    -SteveZ

Reply Children
No Data