宠物店修改
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "EGOCache.h"
|
||||
@interface DataCenter : NSObject
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
-(void)setValue:(id)value forKey:(NSString*)key;
|
||||
// 获取数据
|
||||
-(id)valueForKey:(NSString*)key;
|
||||
@property (nonatomic, strong) EGOCache *cache;
|
||||
-(void)cacheinit:(NSString*)useid;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -44,9 +44,16 @@
|
||||
_dict=[[NSMutableDictionary alloc]init];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)cacheinit:(NSString*)useid
|
||||
{
|
||||
NSArray*arr=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
self.cache = [[EGOCache alloc] initWithCacheDirectory:[arr.firstObject stringByAppendingPathComponent:[NSString stringWithFormat:@"ifish/%@",[CommonUtils getNotNilStr:useid]]]];
|
||||
[self.cache setDefaultTimeoutInterval:864000000];
|
||||
}
|
||||
//根据文件名 获取指定文件名的在沙盒Documents的 全路径
|
||||
-(NSString*)getFullFilePathWithName:(NSString *)name{
|
||||
//方法1
|
||||
|
||||
@@ -57,5 +57,6 @@
|
||||
//新绚多
|
||||
+(void)saveNewXuToControlName:(XuToControlName *)nameModel;
|
||||
+(XuToControlName *)currentNewXuToControlName:(NSString *)macaddress;
|
||||
+(XuToControlName *)currentPetsXuToControlName:(NSString *)macaddress;
|
||||
|
||||
@end
|
||||
|
||||
@@ -241,6 +241,26 @@
|
||||
return controlName;
|
||||
|
||||
}
|
||||
+(XuToControlName *)currentPetsXuToControlName:(NSString *)macaddress
|
||||
{
|
||||
NSString *key = [NSString stringWithFormat:@"newXuTo%@",macaddress];
|
||||
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
|
||||
XuToControlName *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
|
||||
if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
|
||||
controlName = [[XuToControlName alloc] init];
|
||||
controlName.shajunLight = @"杀菌灯";
|
||||
controlName.zengyangPump = @"换气";
|
||||
controlName.light1 = @"杀菌";
|
||||
controlName.light2 = @"恒温";
|
||||
controlName.zaolangPump = @"造浪泵";
|
||||
controlName.huLiDeng = @"护理灯";
|
||||
controlName.xunhuanPump = @"照明";
|
||||
controlName.jiaRe = @"加热棒";
|
||||
controlName.macAddress = macaddress;
|
||||
}
|
||||
return controlName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// EGOCache.h
|
||||
// enormego
|
||||
//
|
||||
// Created by Shaun Harrison.
|
||||
// Copyright (c) 2009-2017 enormego.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_OSX
|
||||
#import <AppKit/AppKit.h>
|
||||
#endif
|
||||
|
||||
//! Project version number for EGOCache.
|
||||
FOUNDATION_EXPORT double EGOCacheVersionNumber;
|
||||
|
||||
//! Project version string for EGOCache.
|
||||
FOUNDATION_EXPORT const unsigned char EGOCacheVersionString[];
|
||||
|
||||
#if !__has_feature(nullability)
|
||||
# define nullable
|
||||
# define nonnull
|
||||
# define __nullable
|
||||
# define __nonnull
|
||||
#endif
|
||||
|
||||
@interface EGOCache : NSObject
|
||||
|
||||
// Global cache for easy use
|
||||
+ (nonnull instancetype)globalCache;
|
||||
|
||||
// Opitionally create a different EGOCache instance with it's own cache directory
|
||||
- (nonnull instancetype)initWithCacheDirectory:(NSString* __nonnull)cacheDirectory;
|
||||
|
||||
- (void)clearCache;
|
||||
- (void)removeCacheForKey:(NSString* __nonnull)key;
|
||||
|
||||
- (BOOL)hasCacheForKey:(NSString* __nonnull)key;
|
||||
|
||||
- (NSData* __nullable)dataForKey:(NSString* __nonnull)key;
|
||||
- (void)setData:(NSData* __nonnull)data forKey:(NSString* __nonnull)key;
|
||||
- (void)setData:(NSData* __nonnull)data forKey:(NSString* __nonnull)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
||||
|
||||
- (NSString* __nullable)stringForKey:(NSString* __nonnull)key;
|
||||
- (void)setString:(NSString* __nonnull)aString forKey:(NSString* __nonnull)key;
|
||||
- (void)setString:(NSString* __nonnull)aString forKey:(NSString* __nonnull)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
||||
|
||||
- (NSDate* __nullable)dateForKey:(NSString* __nonnull)key;
|
||||
- (NSArray* __nonnull)allKeys;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
- (UIImage* __nullable)imageForKey:(NSString* __nonnull)key;
|
||||
- (void)setImage:(UIImage* __nonnull)anImage forKey:(NSString* __nonnull)key;
|
||||
- (void)setImage:(UIImage* __nonnull)anImage forKey:(NSString* __nonnull)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
||||
#else
|
||||
- (NSImage* __nullable)imageForKey:(NSString* __nonnull)key;
|
||||
- (void)setImage:(NSImage* __nonnull)anImage forKey:(NSString* __nonnull)key;
|
||||
- (void)setImage:(NSImage* __nonnull)anImage forKey:(NSString* __nonnull)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
||||
#endif
|
||||
|
||||
- (NSData* __nullable)plistForKey:(NSString* __nonnull)key;
|
||||
- (void)setPlist:(nonnull id)plistObject forKey:(NSString* __nonnull)key;
|
||||
- (void)setPlist:(nonnull id)plistObject forKey:(NSString* __nonnull)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
||||
|
||||
- (void)copyFilePath:(NSString* __nonnull)filePath asKey:(NSString* __nonnull)key;
|
||||
- (void)copyFilePath:(NSString* __nonnull)filePath asKey:(NSString* __nonnull)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
||||
|
||||
- (nullable id<NSCoding>)objectForKey:(NSString* __nonnull)key;
|
||||
- (void)setObject:(nonnull id<NSCoding>)anObject forKey:(NSString* __nonnull)key;
|
||||
- (void)setObject:(nonnull id<NSCoding>)anObject forKey:(NSString* __nonnull)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
|
||||
|
||||
@property(nonatomic) NSTimeInterval defaultTimeoutInterval; // Default is 1 day
|
||||
@end
|
||||
Executable
+368
@@ -0,0 +1,368 @@
|
||||
//
|
||||
// EGOCache.m
|
||||
// enormego
|
||||
//
|
||||
// Created by Shaun Harrison.
|
||||
// Copyright (c) 2009-2017 enormego.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
#import "EGOCache.h"
|
||||
|
||||
#if DEBUG
|
||||
# define CHECK_FOR_EGOCACHE_PLIST() if([key isEqualToString:@"EGOCache.plist"]) { \
|
||||
NSLog(@"EGOCache.plist is a reserved key and can not be modified."); \
|
||||
return; }
|
||||
#else
|
||||
# define CHECK_FOR_EGOCACHE_PLIST() if([key isEqualToString:@"EGOCache.plist"]) return;
|
||||
#endif
|
||||
|
||||
static inline NSString* cachePathForKey(NSString* directory, NSString* key) {
|
||||
key = [key stringByReplacingOccurrencesOfString:@"/" withString:@"_"];
|
||||
return [directory stringByAppendingPathComponent:key];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@interface EGOCache () {
|
||||
dispatch_queue_t _cacheInfoQueue;
|
||||
dispatch_queue_t _frozenCacheInfoQueue;
|
||||
dispatch_queue_t _diskQueue;
|
||||
NSMutableDictionary* _cacheInfo;
|
||||
NSString* _directory;
|
||||
BOOL _needsSave;
|
||||
}
|
||||
|
||||
@property(nonatomic,copy) NSDictionary* frozenCacheInfo;
|
||||
@end
|
||||
|
||||
@implementation EGOCache
|
||||
|
||||
+ (instancetype)globalCache {
|
||||
static id instance;
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
instance = [[[self class] alloc] init];
|
||||
});
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
NSString* cachesDirectory = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
|
||||
NSString* oldCachesDirectory = [[[cachesDirectory stringByAppendingPathComponent:[[NSProcessInfo processInfo] processName]] stringByAppendingPathComponent:@"EGOCache"] copy];
|
||||
|
||||
if([[NSFileManager defaultManager] fileExistsAtPath:oldCachesDirectory]) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:oldCachesDirectory error:NULL];
|
||||
}
|
||||
|
||||
cachesDirectory = [[[cachesDirectory stringByAppendingPathComponent:[[NSBundle mainBundle] bundleIdentifier]] stringByAppendingPathComponent:@"EGOCache"] copy];
|
||||
return [self initWithCacheDirectory:cachesDirectory];
|
||||
}
|
||||
|
||||
- (instancetype)initWithCacheDirectory:(NSString*)cacheDirectory {
|
||||
if((self = [super init])) {
|
||||
_cacheInfoQueue = dispatch_queue_create("com.enormego.egocache.info", DISPATCH_QUEUE_SERIAL);
|
||||
dispatch_queue_t priority = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
|
||||
dispatch_set_target_queue(priority, _cacheInfoQueue);
|
||||
|
||||
_frozenCacheInfoQueue = dispatch_queue_create("com.enormego.egocache.info.frozen", DISPATCH_QUEUE_SERIAL);
|
||||
priority = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
|
||||
dispatch_set_target_queue(priority, _frozenCacheInfoQueue);
|
||||
|
||||
_diskQueue = dispatch_queue_create("com.enormego.egocache.disk", DISPATCH_QUEUE_CONCURRENT);
|
||||
priority = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
|
||||
dispatch_set_target_queue(priority, _diskQueue);
|
||||
|
||||
|
||||
_directory = cacheDirectory;
|
||||
|
||||
_cacheInfo = [[NSDictionary dictionaryWithContentsOfFile:cachePathForKey(_directory, @"EGOCache.plist")] mutableCopy];
|
||||
|
||||
if(!_cacheInfo) {
|
||||
_cacheInfo = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
|
||||
[[NSFileManager defaultManager] createDirectoryAtPath:_directory withIntermediateDirectories:YES attributes:nil error:NULL];
|
||||
|
||||
NSTimeInterval now = [[NSDate date] timeIntervalSinceReferenceDate];
|
||||
NSMutableArray* removedKeys = [[NSMutableArray alloc] init];
|
||||
|
||||
for(NSString* key in _cacheInfo) {
|
||||
if([_cacheInfo[key] timeIntervalSinceReferenceDate] <= now) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:cachePathForKey(_directory, key) error:NULL];
|
||||
[removedKeys addObject:key];
|
||||
}
|
||||
}
|
||||
|
||||
[_cacheInfo removeObjectsForKeys:removedKeys];
|
||||
self.frozenCacheInfo = _cacheInfo;
|
||||
[self setDefaultTimeoutInterval:86400];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)clearCache {
|
||||
dispatch_sync(_cacheInfoQueue, ^{
|
||||
for(NSString* key in _cacheInfo) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:cachePathForKey(_directory, key) error:NULL];
|
||||
}
|
||||
|
||||
[_cacheInfo removeAllObjects];
|
||||
|
||||
dispatch_sync(_frozenCacheInfoQueue, ^{
|
||||
self.frozenCacheInfo = [_cacheInfo copy];
|
||||
});
|
||||
|
||||
[self setNeedsSave];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)removeCacheForKey:(NSString*)key {
|
||||
CHECK_FOR_EGOCACHE_PLIST();
|
||||
|
||||
dispatch_async(_diskQueue, ^{
|
||||
[[NSFileManager defaultManager] removeItemAtPath:cachePathForKey(_directory, key) error:NULL];
|
||||
});
|
||||
|
||||
[self setCacheTimeoutInterval:0 forKey:key];
|
||||
}
|
||||
|
||||
- (BOOL)hasCacheForKey:(NSString*)key {
|
||||
NSDate* date = [self dateForKey:key];
|
||||
if(date == nil) return NO;
|
||||
if([date timeIntervalSinceReferenceDate] < CFAbsoluteTimeGetCurrent()) return NO;
|
||||
|
||||
return [[NSFileManager defaultManager] fileExistsAtPath:cachePathForKey(_directory, key)];
|
||||
}
|
||||
|
||||
- (NSDate*)dateForKey:(NSString*)key {
|
||||
__block NSDate* date = nil;
|
||||
|
||||
dispatch_sync(_frozenCacheInfoQueue, ^{
|
||||
date = (self.frozenCacheInfo)[key];
|
||||
});
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
- (NSArray*)allKeys {
|
||||
__block NSArray* keys = nil;
|
||||
|
||||
dispatch_sync(_frozenCacheInfoQueue, ^{
|
||||
keys = [self.frozenCacheInfo allKeys];
|
||||
});
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
- (void)setCacheTimeoutInterval:(NSTimeInterval)timeoutInterval forKey:(NSString*)key {
|
||||
NSDate* date = timeoutInterval > 0 ? [NSDate dateWithTimeIntervalSinceNow:timeoutInterval] : nil;
|
||||
|
||||
// Temporarily store in the frozen state for quick reads
|
||||
dispatch_sync(_frozenCacheInfoQueue, ^{
|
||||
NSMutableDictionary* info = [self.frozenCacheInfo mutableCopy];
|
||||
|
||||
if(date) {
|
||||
info[key] = date;
|
||||
} else {
|
||||
[info removeObjectForKey:key];
|
||||
}
|
||||
|
||||
self.frozenCacheInfo = info;
|
||||
});
|
||||
|
||||
// Save the final copy (this may be blocked by other operations)
|
||||
dispatch_async(_cacheInfoQueue, ^{
|
||||
if(date) {
|
||||
_cacheInfo[key] = date;
|
||||
} else {
|
||||
[_cacheInfo removeObjectForKey:key];
|
||||
}
|
||||
|
||||
dispatch_sync(_frozenCacheInfoQueue, ^{
|
||||
self.frozenCacheInfo = [_cacheInfo copy];
|
||||
});
|
||||
|
||||
[self setNeedsSave];
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Copy file methods
|
||||
|
||||
- (void)copyFilePath:(NSString*)filePath asKey:(NSString*)key {
|
||||
[self copyFilePath:filePath asKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
||||
}
|
||||
|
||||
- (void)copyFilePath:(NSString*)filePath asKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
||||
dispatch_async(_diskQueue, ^{
|
||||
[[NSFileManager defaultManager] copyItemAtPath:filePath toPath:cachePathForKey(_directory, key) error:NULL];
|
||||
});
|
||||
|
||||
[self setCacheTimeoutInterval:timeoutInterval forKey:key];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Data methods
|
||||
|
||||
- (void)setData:(NSData*)data forKey:(NSString*)key {
|
||||
[self setData:data forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
||||
}
|
||||
|
||||
- (void)setData:(NSData*)data forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
||||
CHECK_FOR_EGOCACHE_PLIST();
|
||||
|
||||
NSString* cachePath = cachePathForKey(_directory, key);
|
||||
|
||||
dispatch_async(_diskQueue, ^{
|
||||
[data writeToFile:cachePath atomically:YES];
|
||||
});
|
||||
|
||||
[self setCacheTimeoutInterval:timeoutInterval forKey:key];
|
||||
}
|
||||
|
||||
- (void)setNeedsSave {
|
||||
dispatch_async(_cacheInfoQueue, ^{
|
||||
if(_needsSave) return;
|
||||
_needsSave = YES;
|
||||
|
||||
double delayInSeconds = 0.5;
|
||||
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
|
||||
dispatch_after(popTime, _cacheInfoQueue, ^(void){
|
||||
if(!_needsSave) return;
|
||||
[_cacheInfo writeToFile:cachePathForKey(_directory, @"EGOCache.plist") atomically:YES];
|
||||
_needsSave = NO;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
- (NSData*)dataForKey:(NSString*)key {
|
||||
if([self hasCacheForKey:key]) {
|
||||
return [NSData dataWithContentsOfFile:cachePathForKey(_directory, key) options:0 error:NULL];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark String methods
|
||||
|
||||
- (NSString*)stringForKey:(NSString*)key {
|
||||
return [[NSString alloc] initWithData:[self dataForKey:key] encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
- (void)setString:(NSString*)aString forKey:(NSString*)key {
|
||||
[self setString:aString forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
||||
}
|
||||
|
||||
- (void)setString:(NSString*)aString forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
||||
[self setData:[aString dataUsingEncoding:NSUTF8StringEncoding] forKey:key withTimeoutInterval:timeoutInterval];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Image methds
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
- (UIImage*)imageForKey:(NSString*)key {
|
||||
UIImage* image = nil;
|
||||
|
||||
@try {
|
||||
image = [NSKeyedUnarchiver unarchiveObjectWithFile:cachePathForKey(_directory, key)];
|
||||
} @catch (NSException* e) {
|
||||
// Surpress any unarchiving exceptions and continue with nil
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
- (void)setImage:(UIImage*)anImage forKey:(NSString*)key {
|
||||
[self setImage:anImage forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
||||
}
|
||||
|
||||
- (void)setImage:(UIImage*)anImage forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
||||
@try {
|
||||
// Using NSKeyedArchiver preserves all information such as scale, orientation, and the proper image format instead of saving everything as pngs
|
||||
[self setData:[NSKeyedArchiver archivedDataWithRootObject:anImage] forKey:key withTimeoutInterval:timeoutInterval];
|
||||
} @catch (NSException* e) {
|
||||
// Something went wrong, but we'll fail silently.
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
- (NSImage*)imageForKey:(NSString*)key {
|
||||
return [[NSImage alloc] initWithData:[self dataForKey:key]];
|
||||
}
|
||||
|
||||
- (void)setImage:(NSImage*)anImage forKey:(NSString*)key {
|
||||
[self setImage:anImage forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
||||
}
|
||||
|
||||
- (void)setImage:(NSImage*)anImage forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
||||
[self setData:[[NSBitmapImageRep imageRepWithData:anImage.TIFFRepresentation] representationUsingType:NSPNGFileType properties:@{ }] forKey:key withTimeoutInterval:timeoutInterval];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Property List methods
|
||||
|
||||
- (NSData*)plistForKey:(NSString*)key; {
|
||||
NSData* plistData = [self dataForKey:key];
|
||||
return [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListImmutable format:nil error:nil];
|
||||
}
|
||||
|
||||
- (void)setPlist:(id)plistObject forKey:(NSString*)key; {
|
||||
[self setPlist:plistObject forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
||||
}
|
||||
|
||||
- (void)setPlist:(id)plistObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval; {
|
||||
// Binary plists are used over XML for better performance
|
||||
NSData* plistData = [NSPropertyListSerialization dataWithPropertyList:plistObject format:NSPropertyListBinaryFormat_v1_0 options:0 error:nil];
|
||||
|
||||
if(plistData != nil) {
|
||||
[self setData:plistData forKey:key withTimeoutInterval:timeoutInterval];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Object methods
|
||||
|
||||
- (id<NSCoding>)objectForKey:(NSString*)key {
|
||||
if([self hasCacheForKey:key]) {
|
||||
return [NSKeyedUnarchiver unarchiveObjectWithData:[self dataForKey:key]];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setObject:(id<NSCoding>)anObject forKey:(NSString*)key {
|
||||
[self setObject:anObject forKey:key withTimeoutInterval:self.defaultTimeoutInterval];
|
||||
}
|
||||
|
||||
- (void)setObject:(id<NSCoding>)anObject forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval {
|
||||
[self setData:[NSKeyedArchiver archivedDataWithRootObject:anObject] forKey:key withTimeoutInterval:timeoutInterval];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -313,10 +313,24 @@ methodType url : (NSString *)url
|
||||
failure:(void (^)(NSError* err))failure
|
||||
{
|
||||
|
||||
NSString*macid=[[deviceId componentsSeparatedByString:@"_"] firstObject];
|
||||
|
||||
NSString*deviceType=[[deviceId componentsSeparatedByString:@"_"] lastObject];
|
||||
|
||||
NSString*type=@"0";//0换水 1杀菌
|
||||
|
||||
if ([deviceType isEqualToString:@"3f"])
|
||||
{
|
||||
type=@"1";
|
||||
}
|
||||
|
||||
|
||||
|
||||
NSDictionary*para=@{
|
||||
@"deviceId":deviceId,
|
||||
@"deviceId":macid,
|
||||
@"waterRemind":waterRemind,
|
||||
@"remindCycle":remindCycle
|
||||
@"remindCycle":remindCycle,
|
||||
@"type":type
|
||||
|
||||
};
|
||||
[AFNOHeaderHttpTool requestWihtMethod:RequestTypePost url:kSetRemindWaterInf params:para success:success failure:failure];
|
||||
|
||||
@@ -173,6 +173,13 @@
|
||||
UINavigationController *xuanduo2fNav=[[UINavigationController alloc]initWithRootViewController:xuanduo2fVc];
|
||||
[UIApplication sharedApplication].delegate.window.rootViewController = xuanduo2fNav;
|
||||
}
|
||||
else if([devicemodel.type isEqualToString:DECICE_TYPE_XUANDUO3F]){
|
||||
//绚多新设备
|
||||
Xuanduo2fController *xuanduo2fVc = [Xuanduo2fController new];
|
||||
xuanduo2fVc.currentDevice = devicemodel;
|
||||
UINavigationController *xuanduo2fNav=[[UINavigationController alloc]initWithRootViewController:xuanduo2fVc];
|
||||
[UIApplication sharedApplication].delegate.window.rootViewController = xuanduo2fNav;
|
||||
}
|
||||
else{
|
||||
|
||||
int controlAmount=[devicemodel.controlAmount intValue];
|
||||
|
||||
@@ -32,7 +32,9 @@
|
||||
|
||||
NSDictionary *userDic=dataDic[@"userInfo"];
|
||||
UserModel *model=[[UserModel alloc] initWithDict:userDic];
|
||||
|
||||
[[DataCenter defaultDtacenter]setValue:model forKey:@"UserLogIn"];
|
||||
[[DataCenter defaultDtacenter] cacheinit:[model.userId stringValue]];
|
||||
|
||||
//金币任务等级
|
||||
NSDictionary *userAssetDic=dataDic[@"userAsset"];
|
||||
@@ -88,6 +90,7 @@
|
||||
NSDictionary *userDic=dataDic[@"userInfo"];
|
||||
UserModel *model=[[UserModel alloc] initWithDict:userDic];
|
||||
[[DataCenter defaultDtacenter]setValue:model forKey:@"UserLogIn"];
|
||||
[[DataCenter defaultDtacenter] cacheinit:[model.userId stringValue]];
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
if (model.unionId.length) {
|
||||
[userdefult setObject:model.unionId forKey:@"unionId"];
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define DECICE_TYPE_XUANDUOOF @"0f" //0x0f//无屏幕
|
||||
#define DECICE_TYPE_XUANDUO1F @"1f" //0x1f//有屏幕
|
||||
#define DECICE_TYPE_XUANDUO2F @"2f" //新设备
|
||||
#define DECICE_TYPE_XUANDUO3F @"3f" //宠物笼
|
||||
|
||||
//可丽爱
|
||||
#define DECICE_TYPE_KELIAI @"aa" //0xaa
|
||||
|
||||
@@ -157,7 +157,10 @@
|
||||
NSString*startTimeHex1=[backModel.timer1 substringWithRange:NSMakeRange(4, 4)];
|
||||
NSString*endTimeHex1=[backModel.timer1 substringWithRange:NSMakeRange(8, 4)];
|
||||
|
||||
|
||||
if (!backModel.timer1)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
// 十进制
|
||||
NSString*startTimeTen1=[dataContorl hexStringToDateString:startTimeHex1];
|
||||
NSString*endTimeTen1=[dataContorl hexStringToDateString:endTimeHex1];
|
||||
|
||||
Reference in New Issue
Block a user