在视图控制器之间传递时为空值

时间:2016-07-20 19:17:03

标签: ios objective-c segue

这让我疯了,因为它以前从来没有发生在我身上,而且我做了几十次。

在两个视图控制器之间传递值会导致值为Traceback (most recent call last): File "/usr/lib/python3.4/urllib/request.py", line 1182, in do_open h.request(req.get_method(), req.selector, req.data, headers) File "/usr/lib/python3.4/http/client.py", line 1088, in request self._send_request(method, url, body, headers) File "/usr/lib/python3.4/http/client.py", line 1126, in _send_request self.endheaders(body) File "/usr/lib/python3.4/http/client.py", line 1084, in endheaders self._send_output(message_body) File "/usr/lib/python3.4/http/client.py", line 922, in _send_output self.send(msg) File "/usr/lib/python3.4/http/client.py", line 857, in send self.connect() File "/usr/lib/python3.4/http/client.py", line 834, in connect self.timeout, self.source_address) File "/usr/lib/python3.4/socket.py", line 512, in create_connection raise err File "/usr/lib/python3.4/socket.py", line 503, in create_connection sock.connect(sa) TimeoutError: [Errno 110] Connection timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/maxlagerz/PycharmProjects/AbitLogger/main.py", line 58, in <module> main() File "/home/maxlagerz/PycharmProjects/AbitLogger/main.py", line 53, in main parse(get_html(url), url) File "/home/maxlagerz/PycharmProjects/AbitLogger/main.py", line 22, in get_html response = urllib.request.urlopen(url) File "/usr/lib/python3.4/urllib/request.py", line 161, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python3.4/urllib/request.py", line 463, in open response = self._open(req, data) File "/usr/lib/python3.4/urllib/request.py", line 481, in _open '_open', req) File "/usr/lib/python3.4/urllib/request.py", line 441, in _call_chain result = func(*args) File "/usr/lib/python3.4/urllib/request.py", line 1210, in http_open return self.do_open(http.client.HTTPConnection, req) File "/usr/lib/python3.4/urllib/request.py", line 1184, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno 110] Connection timed out>

我有一个NULL方法:

prepareForSegue:

但是当执行segue时,我尝试记录- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString: @"LoginSegue"]) { UITabBarController *destinationTabController = [segue destinationViewController]; ViewController *destinationViewController = destinationTabController.selectedViewController; NSLog(@"Logged user is %@.", loggedUser); //This prints out the user correctly destinationViewController.currentUser = loggedUser; } } 值,它是currentUser

任何想法,伙计们?

1 个答案:

答案 0 :(得分:2)

标签栏控制器不在界面中,因此未选择任何内容。因此,destinationViewControllernil,您尝试设置其currentUser无效。