【发布时间】:2016-11-01 12:08:27
【问题描述】:
我正在尝试将代码从 swift xcode 转换为 c# (xamarin)。我看不懂下面的代码:
#pragma mark - Implement DTBackgroundView Class
@interface DTBackgroundView : UIView
{
UIWindow *_previousKeyWindow;
UIWindow *_alertWindow;
NSMutableArray *_alertViews;
}
+ (Instancetype)currentBackground;
static DTBackgroundView *singletion = nil;
@implementation DTBackgroundView
+ (Instancetype)currentBackground
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
singletion = [DTBackgroundView new];
});
return singletion;
}
我的问题是:
currentBackground是谁?
以下代码中的backgroundView是什么:
DTBackgroundView *backgroundView = [DTBackgroundView currentBackground];
【问题讨论】:
-
您需要查阅designPatterns 书籍来了解singleton 类。而且您发布的代码不在 Swift 它的 Objective-C 中。
标签: c# ios objective-c xcode xamarin