【发布时间】:2014-03-21 16:52:55
【问题描述】:
在应用程序中,我正在使应用程序从网络服务中获取值,以检查是否有人在关注其他人。当值为 YES 时,滑块必须更新为 ON。当我更新 ViewDidLoad 中的开关时,开关会更新。在 web 服务后的代码中,检查开关是否打开。 “是,用户正在关注”确实显示在日志文件中。
if ([data length] >0 && error == nil){
NSString *html = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", html);
if ([html isEqualToString:@"isfollowing"]) {
NSLog(@"YES, user is following");
SwitchOutlet.on = YES;
}
}
【问题讨论】:
-
在
SwitchOutlet.on = YES;处进入调试器并确保SwitchOutlet不为零。 -
你应该在主线程中更新你的 UI。