歸檔解檔

@interface JAXOneShipCompany : NSObject <NSCoding>

@property (nonatomic, strong, readonly) NSString *ID;
@property (nonatomic, strong, readonly) NSString *NameCN;
@property (nonatomic, strong, readonly) NSString *NameEN;
@property (nonatomic, assign, readonly) NSInteger OrderIndex;
@property (nonatomic, strong, readonly) NSString *Remark;
@property (nonatomic, strong, readonly) NSString *SCAC;

@end

@implementation JAXOneShipCompany

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super init]) {
        _ID = [aDecoder decodeObjectForKey:@"ID"];
        _NameCN = [aDecoder decodeObjectForKey:@"NameCN"];
        _NameEN = [aDecoder decodeObjectForKey:@"NameEN"];
        _OrderIndex = [[aDecoder decodeObjectForKey:@"OrderIndex"] integerValue];
        _Remark = [aDecoder decodeObjectForKey:@"Remark"];
        _SCAC = [aDecoder decodeObjectForKey:@"SCAC"];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:_ID forKey:@"ID"];
    [aCoder encodeObject:_NameCN forKey:@"NameCN"];
    [aCoder encodeObject:_NameEN forKey:@"NameEN"];
    [aCoder encodeObject:@(_OrderIndex) forKey:@"OrderIndex"];
    [aCoder encodeObject:_Remark forKey:@"Remark"];
    [aCoder encodeObject:_SCAC forKey:@"SCAC"];
}

- (NSString *)description {
    return [NSString stringWithFormat:@"<%@: %p, %@>",
            [self class],
            self,
            @{
              @"ID" : _ID,
              @"NameCN" : _NameCN,
              @"NameEN" : _NameEN,
              @"OrderIndex" : @(_OrderIndex),
              @"Remark" : _Remark,
              @"SCAC" : _SCAC
              }
            ];
}

@end

歸檔

  static NSString *const kHistoryFscPath = @"JAX_kHistoryFscPath.txt";

  - (NSString *)private_kHistoryFscPath {
      return [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent: kHistoryFscPath];
  }

  if (![NSKeyedArchiver archiveRootObject:self.historyFsc toFile:[self private_kHistoryFscPath]]) {
      NSLog(@"NSKeyedArchiver Error!");
  }

解檔

  self.historyFsc = [NSKeyedUnarchiver unarchiveObjectWithFile:[self private_kHistoryFscPath]];
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容