ios - self 指的是谁?
阿神
阿神 2017-04-17 15:00:42
0
6
324
#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學習者快速成長!