我尝试为UILabel获得随机颜色......
- (UIColor *)randomColor
{
int red = arc4random() % 255 / 255.0;
int green = arc4random() % 255 / 255.0;
int blue = arc4random() % 255 / 255.0;
UIColor *color = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
NSLog(@"%@", color);
return color;
}
Run Code Online (Sandbox Code Playgroud)
并使用它:
[mat addAttributes:@{NSForegroundColorAttributeName : [self randomColor]} range:range];
Run Code Online (Sandbox Code Playgroud)
但颜色总是黑色的.怎么了?
PS抱歉我的英文)
我正在尝试在我的iOS应用中实施Firebase远程配置.一切正常,但有一个问题 - 远程配置总是从firebase服务器获取数据,而不是从缓存中获取数据.我尝试过很多变种而没有任何成功.这是我的代码:
+ (instancetype)sharedInstance
{
static ConfigManager *_sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedInstance = [[self alloc] init];
});
return _sharedInstance;
}
-(instancetype)init
{
self = [super init];
if (self) {
self.remoteConfig = [FIRRemoteConfig remoteConfig];
[self updateRemoteConfig];
}
return self;
}
- (void)activateDebugMode
{
FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:YES];
self.remoteConfig.configSettings = remoteConfigSettings;
}
- (void)updateRemoteConfig
{
[self fetchConfigWithCompletionHandler:nil];
}
- (void)fetchConfigWithCompletionHandler: (FireBaseConfigCompletionHandler)completionHandler
{
NSTimeInterval cacheExpiration = 43200;
BOOL debug = ConfigurationValue(DebugMode);
if (debug) {
cacheExpiration = …
Run Code Online (Sandbox Code Playgroud)