// // ProjectInfoSave.m // UUTUtils // // Created by zhuge on 2017/12/22. // Copyright © 2017年 zhuge. All rights reserved. // #import "ProjectInfoSave.h" #import "EditProjectWC.h" @implementation ProjectInfoSave - (instancetype)init { self = [super init]; if (self) { // self.adIdIndexArray = [[NSMutableArray alloc] init]; self.adIdIndexDictionary = [[NSMutableDictionary alloc] init]; } return self; } + (ProjectInfoSave *)share{ static ProjectInfoSave * s_instance_ProjectInfoSave = nil ; if (s_instance_ProjectInfoSave == nil) { s_instance_ProjectInfoSave = [[ProjectInfoSave alloc] init]; } return (ProjectInfoSave *)s_instance_ProjectInfoSave; } //- (void)addAdIdIndex:(NSString*) adIdIndex{ // [_adIdIndexArray addObject:adIdIndex]; //} //- (BOOL)isAdIdIndexSave:(NSString*) adIdIndex{ // return [_adIdIndexArray containsObject:adIdIndex]; //} - (void)clearAdIdIndex{ // [_adIdIndexArray removeAllObjects]; [_adIdIndexDictionary removeAllObjects]; } - (void)setCurAdIdNeedType:(int) adType{ _curAdType = adType; } - (BOOL)isSameTypeForAdIdIndex:(NSString*) adIdIndex{ NSNumber* adIdType = [_adIdIndexDictionary objectForKey:adIdIndex]; if(adIdType==nil){ NSString* mes = [NSString stringWithFormat:@"\n\n使用了不存在的广告id:%@",adIdIndex]; [EditProjectWC alertWithError:mes]; return false; } int curIdType = (int)[adIdType integerValue]/100; if(_curAdType == curIdType){ return true; }else if(curIdType == 1 && _curAdType==2){ return true; } NSString* mes = [NSString stringWithFormat:@"\n\n使用的广告id:%@与版位类型不匹配",adIdIndex]; [EditProjectWC alertWithError:mes]; return false; } - (BOOL)isBannerTimeOk:(int) bannerSec{ if(bannerSec<30 || bannerSec > 90){ NSString* mes = [NSString stringWithFormat:@"\n\nBanner刷新时间不能低于30秒或者大于90秒。当前Banner刷新时间:%d",bannerSec]; [EditProjectWC alertWithError:mes]; return false; } return true; } - (void)addAdIdIndexType:(NSString*) adIdIndex :(NSNumber*)adIdType{ [_adIdIndexDictionary setObject:adIdType forKey:adIdIndex]; } @end