dequeueReusableCellWithIdentifier: deletes the cell it is supposed to return #138

Open
dtartaglia opened this Issue May 24, 2012 · 12 comments

Comments

Projects
None yet
7 participants

the method should retain the cell before removing it from cells and the autorelease it just before returning it. Proposed solution:

  • (AQGridViewCell *) dequeueReusableCellWithIdentifier: (NSString *) reuseIdentifier
    {
    NSMutableSet * cells = [_reusableGridCells objectForKey: reuseIdentifier];
    AQGridViewCell * cell = [cells anyObject];
    [cell prepareForReuse];
    [cell retain];
    if (cell) {
    [cells removeObject: cell];
    }
    return [cell autorelease];
    }

venkatd commented Jul 5, 2012

I was running into issues with this also

- (AQGridViewCell *) dequeueReusableCellWithIdentifier: (NSString *) reuseIdentifier
{
    NSMutableSet * cells = [_reusableGridCells objectForKey: reuseIdentifier];
    AQGridViewCell * cell = [cells anyObject];
    if ( cell == nil )
        return ( nil );

    [cell prepareForReuse];

    /* Added the line below so that a cell doesn't get released IMMEDIATELY after it is removed */
    [[cell retain] autorelease];

    [cells removeObject: cell];

    return ( cell );
}
Contributor

claybridges commented Jul 17, 2012

We are seeing problems which strongly appear that they are related to this.

Maybe this isn't a problem with ARC? I'm not using ARC and I don't think venkatd is either. What about you claybridges?

Contributor

claybridges commented Jul 17, 2012

Same, we are not ARC.

venkatd commented Sep 16, 2012

Not using ARC either.

I am not using ARC and ran into this issue, which led to random crashes that were hard to debug. Everything worked when I got rid of the dequeueReusableCellWithIdentifier call.

Collaborator

evadne commented Sep 20, 2012

Not using ARC is no longer supported. Sorry about that.

On Sep 20, 2012, at 3:22, Tian notifications@github.com wrote:

I am not using ARC and ran into this issue, which led to random crashes
that were hard to debug. Everything worked when I got rid of the
dequeueReusableCellWithIdentifier call.


Reply to this email directly or view it on
GitHubhttps://github.com/AlanQuatermain/AQGridView/issues/138#issuecomment-8722647.

Contributor

claybridges commented Sep 20, 2012

@evadne Are you saying that AQGridView, which is itself fully ARC, cannot be used in a mixed ARC/non-ARC project?

Collaborator

evadne commented Sep 20, 2012

It should work without issues. Cases where it does not work will be
considered high priority bugs.

On Sep 20, 2012, at 11:17, Clay Bridges notifications@github.com wrote:

@evadne https://github.com/evadne Are you saying that AQGridView, which
is itself fully ARC, cannot be used in a mixed ARC/non-ARC project?


Reply to this email directly or view it on
GitHubhttps://github.com/AlanQuatermain/AQGridView/issues/138#issuecomment-8740362.

Owner

AlanQuatermain commented Sep 20, 2012

There shouldn't be any problem linking directly to a prebuilt binary which was built using ARC, but if you're including the source directly you need to set the -fobjc-arc parameter on each AQGridView source file.

Note that the suggested code from Daniel Tartaglia at the start of this thread is only necessary when compiling AQGridView itself without ARC support — which, as @evadne rightly stated, is no longer supported.

Contributor

claybridges commented Sep 20, 2012

My problems were from using the 1.3 CocoaPod version (which is all ARC; -fobjc-arc added automatically from s.requires_arc = true) in our primarily non-ARC app.

Thank you!! . This article very help full for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment