NSKeyedArchiver:对象序列化,将对象保存在文件里

NSKeyedUnarchiver:反序列化

 

#if ARCHIVE

// create and archive a roster

Roster *roster = [[Roster alloc] init];

[roster create];

[NSKeyedArchiver archiveRootObject:roster toFile:fileName];

[roster release];

#endif

#if UNARCHIVE

// unarchive roster

Roster *unarchive = [NSKeyedUnarchiver unarchiveObjectWithFile:fileName];

[unarchive print];

for (Athlete *athlete in [unarchive athletes])

[athlete print];

    [unarchive release];

#endif

    [pool release];

    return 0; 

相关文章:

  • 2022-12-23
  • 2020-02-15
  • 2021-08-04
  • 2021-06-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
  • 2021-11-16
  • 2021-08-22
  • 2021-08-22
  • 2021-07-18
相关资源
相似解决方案