我是 NSCache 的新手,我想缓存响应数据并使用它。所以我[cache setobject]
在 A 类,我需要从 B 类使用[cache objectForKey]
. 但它总是NULL
。它在下面的同一类中工作。
NSURL *url = [NSURL URLWithString:@"http://ios.eezytutorials.com/sample-files/sample-dictionary-plist.plist"];
NSDictionary *dict = [[NSDictionary alloc]initWithContentsOfURL:url];
NSCache *cache = [[NSCache alloc]init];
[cache setObject:dict forKey:url];
NSLog(@"%@",[cache objectForKey:url]);
如何从不同的班级获得?