AQGridView icon indicating copy to clipboard operation
AQGridView copied to clipboard

dequeueReusableCellWithIdentifier: deletes the cell it is supposed to return

Open danielt1263 opened this issue 12 years ago • 12 comments

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]; }

danielt1263 avatar May 24 '12 20:05 danielt1263

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 );
}

venkatd avatar Jul 05 '12 18:07 venkatd

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

claybridges avatar Jul 17 '12 14:07 claybridges

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?

danielt1263 avatar Jul 17 '12 16:07 danielt1263

Same, we are not ARC.

claybridges avatar Jul 17 '12 16:07 claybridges

Not using ARC either.

venkatd avatar Sep 16 '12 15:09 venkatd

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.

classbox avatar Sep 20 '12 10:09 classbox

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

On Sep 20, 2012, at 3:22, Tian [email protected] 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.

evadne avatar Sep 20 '12 17:09 evadne

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

claybridges avatar Sep 20 '12 18:09 claybridges

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 [email protected] 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.

evadne avatar Sep 20 '12 18:09 evadne

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.

AlanQuatermain avatar Sep 20 '12 18:09 AlanQuatermain

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.

claybridges avatar Sep 20 '12 19:09 claybridges

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

maheshmobileApp avatar Apr 07 '16 10:04 maheshmobileApp