我试图在应用程序启动后在模式视图中显示我的远程配置设置。一切都已正确连接,但视图会在configs
对象从其NSURLConnection
委托方法更新之前更新其标签。
我正在寻找一种解决方案,让委托方法在我尝试更新视图之前完成。我宁愿不将功能放在委托方法本身中,以便MYRemoteConfig
在其他情况下使用。
我怀疑解决方案是显而易见的,但是我看这个太久了。
在viewDidAppear{}
中MYSettingsViewController.m
MYRemoteConfig* config = [[MYRemoteConfig alloc] init];
[configs updateSettings]; // I need these delegate methods to be done
// before the next line
self.customerLabel.text = configs.customer; // Updates with empty box
self.courseLabel.text = configs.course;
-
updateSettings{}
在MYRemoteConfig.m
// code that gets uuid and sets up post request //
NSURLConnection* connection = [NSURLConnection connectionWithRequest:request
delegate:self];
[connection start];
NSLog(@"Connection should have started.");
然后在connectionDidFinishLoading{}
:(将数据附加到本地变量之后)
// pull JSON objects into dictionary
[self updateProfile:settingsDictionary;
NSLog(@"%@", settingsDictionary); //works
updateProfile{}
:
// code that sets config attributes in singleton object //
self.customer = [settings objectForKey:@"Customer"]; // I need this data
self.course = [settings objectForKey:@"Course"]; // in my view controller