ios - self 指的是谁?
阿神
阿神 2017-04-17 15:00:42
0
6
326
#import "RootViewController.h"
#import "FavoritesList.h"

@interface RootViewController ()

@property (copy,nonatomic) NSArray *familyName;
@property (assign,nonatomic) CGFloat cellPointSize;
@property (strong,nonatomic) FavoritesList *favoritesList;

@end
@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.familyName = [[UIFont familyNames] sortedArrayUsingSelector:@selector(compare:)];
    UIFont *preferredTableViewFont = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
    self.cellPointSize = preferredTableViewFont.pointSize;
    self.favoritesList = [FavoritesList sharedFavoritesList];   
}
- (void)viewWillAppear:(BOOL)animated {
    [self.tableView reloadData];
}
@end

该段代码中的self 分别指的是谁 新手望指教

阿神
阿神

闭关修行中......

모든 응답(6)
刘奇

self指的是RootViewController类的实例,是对当前对象的引用,跟js里的this一个意思。

Ty80

面向对象语言中,方法和成员变量的访问都需要通过类的实例(对象)。
所以这个self的意思指的就是当前这个实例(对象)。类似java中的this。

Ty80

Your RootViewController Class

洪涛

谁调用的就指谁

Peter_Zhu

当前类的当前对象,大学老师教的

左手右手慢动作

从一个角度来讲,应该是指向当前对象自己的指针

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!