#import <Foundation/Foundation.h> #import "Observer.h" #import "Person.h" #import "Computer.h" int main(int argc, const char * argv[]) { @autoreleasepool { /* Person *per = [[Person alloc]init]; // Computer *computer1 = [[Computer alloc]init]; // per.computer = [computer1 autorelease]; // [per release]; per.name = [NSString stringWithFormat:@"abc"];//retaincount = 2 per.name = [NSString stringWithFormat:@"bcd"];//2 per.name = nil;//没有 //对象的内存什么时候释放? */ Observer *ob = [[Observer alloc]init]; NSArray *array = @[@"keyword"]; [array writeToFile:@"/Users/wangzheng/Desktop/classSeven.txt" atomically:YES]; NSArray *array1 = [NSArray arrayWithContentsOfFile:@"/Users/wangzheng/Desktop/classSeven.txt"]; NSLog(@"%@",array1); //NSUserDefaults [[NSUserDefaults standardUserDefaults]setObject:@"12345" forKey:@"account"];//将数据存入本地路径(移动设备路径) BOOL succeed = [[NSUserDefaults standardUserDefaults]synchronize]; //获取到Document和Library NSString *account = [[NSUserDefaults standardUserDefaults]objectForKey:@"account"]; NSLog(@"%@",account); //数据持久化 //对象归档 NSKeyedArchiver NSKeyedUnarchiver //网络请求 服务器 // 云 icloud NSLog(@"Hello, World!"); } return 0; }
时间: 2024-10-04 08:04:51