1

Xcode 5 Analyzeがこれについて不平を言う理由を誰かが知っています:

ZIFollowerRequestsCell.m:34:5: '[(super or self) init...]' の結果に設定されていない間に 'self' を返しています

#import "ZIFollowerRequestsCell.h"

@implementation ZIFollowerRequestsCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:@"ZIFollowerRequestsCell" owner:self options:nil];
        self = [nibArray objectAtIndex:0];

        self.profileImageView.image = nil;
        self.profileImageView.userInteractionEnabled = YES;
   }
   return self;
}

@end

@interface ZIFollowerRequestsCell : UITableViewCell <UIGestureRecognizerDelegate>
@end

助けてくれてありがとう。

4

1 に答える 1

2

自己を 2 回割り当てています。2 回目は、Xcode が言ったことです。また、self.variableコンストラクターでは使用せず、単に使用することをお勧めします_variable

セルを登録しましたか?ルート ビューがクラス ZIFollowerRequestsCell のセルである ZIFollowerRequestsCell.xib があると仮定して、View Controller でこれを試してください。

NSString * const REUSE_ID_CELL = @"ZIFollowerRequestsCell";

- (void)registerNIBs
{
    NSBundle *classBundle = [NSBundle bundleForClass:[ZIFollowerRequestsCell class]];
    UINib *nib = [UINib nibWithNibName:REUSE_ID_CELL bundle:classBundle];
    [[self tableView] registerNib:topNib forCellReuseIdentifier:REUSE_ID_CELL];
}

- (NSString *)reuseIdentifierForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return REUSE_ID_CELL; 
}

- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *reuseID = [self reuseIdentifierForRowAtIndexPath:indexPath];
    UITableViewCell *cell = [[self tableView] dequeueReusableCellWithIdentifier:reuseID];
    return cell; 
}
于 2013-10-03T16:35:48.777 に答える