0
-(IBAction)tapOnLikerImage:(UITapGestureRecognizer*)gestureRecognizer {
    AsyncImageView *likerImageView = (AsyncImageView*)[gestureRecognizer view ];
    NSDictionary * likerdetail = [(NSDictionary*)(likerImageView.tag) retain];
    NSLog(@"frndDetDict2 %@",[(NSDictionary*)(likerImageView.tag) retain]);
}
4

1 回答 1

0

您正在传递一个整数,您应该在其中传递一个 Objective C 对象指针。您可能想从数组中获取字典。

顺便说一句,您的保留释放调用不正确。保留在NSDictionary * likerdetail = [(NSDictionary*)(likerImageView.tag) retain];很好,保留在NSLog(@"frndDetDict2 %@",[(NSDictionary*)(likerImageView.tag) retain]);不是。

更好的方法(非ARC):

-(IBAction)tapOnLikerImage:(UITapGestureRecognizer*)gestureRecognizer {
    AsyncImageView *likerImageView = (AsyncImageView*)[gestureRecognizer view];

    NSDictionary *likerdetail = [[anArray objectAtIndex:(likerImageView.tag)] retain];

    NSLog(@"frndDetDict2 %@", likerdetail);

    [likerdetail release];
}

对于 ARC 代码:

-(IBAction)tapOnLikerImage:(UITapGestureRecognizer*)gestureRecognizer {
    AsyncImageView *likerImageView = (AsyncImageView*)[gestureRecognizer view];

    NSDictionary *likerdetail = [anArray objectAtIndex:(likerImageView.tag)];

    NSLog(@"frndDetDict2 %@", likerdetail);
}

请注意 ARC 代码中没有任何保留和释放:ARC 会自动为您处理。

于 2013-08-22T01:33:00.853 回答