据我所看到的,MKStoreKit检索你的产品的清单是plist中的MKStoreManager.m
下面的方法:
#pragma mark Internal MKStoreKit functions
//line 201 of MKStoreManager.m
- (NSDictionary*) storeKitItems
{
return [NSDictionary dictionaryWithContentsOfFile:
[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"MKStoreKitConfigs.plist"]];
}
所以,如果你只需要改变这种方法调用,例如,获得来自服务器的新项目,您可以实现您需要的结果。
例如,你可能有一些预填充的.plist,然后移动它NUSUserDefaults,就像一个NSDictionary,并且,当来自服务器的新项目来了,你只需更新它。
所以,你的方法会是这个样子:
- (NSDictionary*) storeKitItems
{
if(![[NSUserDefaults standardUserDefaults]valueForKey:@"NewConfigs"])
[[NSUserDefaults standardUserDefaults]setValue:[NSDictionary dictionaryWithDictionary:[NSDictionary dictionaryWithContentsOfFile:
[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"MKStoreKitConfigs.plist"]]] forKey:@"NewConfigs"];
[[NSUserDefaults standardUserDefaults]synchronize];
return [[NSUserDefaults standardUserDefaults]valueForKey:@"NewConfigs"];
}
感谢尼基塔,这基本上就是我所做的。你是对的,MKStoreKit获取它自己的内部plist,所以我只是用我自己的一个查询服务器的方法拦截这个方法(或者在服务器不可用的情况下返回一个缓存的内部列表)。 – Murdock 2012-07-14 01:17:53