使用UItableview在iOS应用开发中实现好友列表功能

2020-01-14 17:58:21于海丽

@property(nonatomic,copy)NSString *intro;
/**
 *  该好友是否是vip
 */
@property(nonatomic,assign,getter = isVip)BOOL vip;

-(instancetype)initWithDict:(NSDictionary *)dict;
+(instancetype)friendsWithDict:(NSDictionary *)dict;
@end


YYFriendsModel.m文件
复制代码
//
//  YYFriendsModel.m
//  02-QQ好友列表(基本数据的加载)
//
//  Created by apple on 14-5-31.
//  Copyright (c) 2014年 itcase. All rights reserved.
//

 

#import "YYFriendsModel.h"

@implementation YYFriendsModel
-(instancetype)initWithDict:(NSDictionary *)dict
{
    if (self=[super init]) {
        [self setValuesForKeysWithDictionary:dict];
    }
    return self;
}

+(instancetype)friendsWithDict:(NSDictionary *)dict
{
    return [[self alloc]initWithDict:dict];
}
@end


视图部分

 

YYfriendCell.h文件

复制代码
//
//  YYfriendCell.h
//  02-QQ好友列表(基本数据的加载)
//
//  Created by apple on 14-5-31.
//  Copyright (c) 2014年 itcase. All rights reserved.
//

 

#import <UIKit/UIKit.h>
@class YYFriendsModel;
@interface YYfriendCell : UITableViewCell

@property(nonatomic,strong)YYFriendsModel *friends;

+(instancetype)cellWithTableview:(UITableView *)tableView;
@end


YYfriendCell.m文件
复制代码
//
//  YYfriendCell.m
//  02-QQ好友列表(基本数据的加载)
//
//  Created by apple on 14-5-31.
//  Copyright (c) 2014年 itcase. All rights reserved.
//

 

#import "YYfriendCell.h"
#import "YYFriendsModel.h"
//私有扩展
@interface YYfriendCell()


@end


复制代码
@implementation YYfriendCell