我正在将我的ViewController
从 Objective-C转换为Swift 。
我想知道 findObjectsInBackgroundWithBlock
是否仍然是最聪明的东西(或者如果加载太慢),如果我应该以相同的方式使用它。
我正在使用它来获取Parse
数据并将其保存到我的App Group
和/或NSUserDefaults
。
// Query Parse
PFQuery *query = [PFQuery queryWithClassName:@"data"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSMutableArray *localMatchup = [@[] mutableCopy];
for (PFObject *object in objects) {
// Add objects to local Arrays
[localMatchup addObject:[object objectForKey:@"matchup"]];
// App Group
NSString *container = @"group.com.ramsden.playoffs";
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:container];
// Matchup
[defaults setObject:localMatchup forKey:@"KeyMatchup"];
NSArray *savedMatchup = [defaults objectForKey:@"KeyMatchup"];
self.matchupArray = localMatchup;
更新:
我在下面尝试了Lamar的答案,但是在findObjectsInBackgroundWithBlock行上出现了错误:'([AnyObject]!, NSError!) -> Void' is not compatible to 'PFArrayResultBlock?
答案 0 :(得分:1)
试试这个:
static shared_ptr<Layer<Dtype> > CreateLayer(const LayerParameter& param)
{
if (Caffe::root_solver()) {
LOG(INFO) << "Creating layer " << param.name();
}
const string& type = param.type();
CreatorRegistry& registry = Registry();
CHECK_EQ(registry.count(type), 1) << "Unknown layer type: " << type
<< " (known types: " << LayerTypeListString() << ")";
return registry[type](param);
}