尝试从firebase数据库到tableview的show image

时间:2017-10-23 09:15:21

标签: ios swift uitableview firebase firebase-realtime-database

我正在尝试从firebase数据库到tableview的show image,但是收到错误。

  

对成员' dataTask的不明确引用(with:completionHandler:)'

import zmq

context = zmq.Context()

upstream_port = 10000
upstream_host = 'localhost'
control_channel_port = 11000
upstream_addr = 'tcp://{}:{}'.format(upstream_host, upstream_port)

def should_grant(request):
    '''
    Permission checking - irrelevant to the question
    '''
    return True


def bind_downstream():
    downstream = context.socket(zmq.PUB)
    addr = 'tcp://*'
    port = downstream.bind_to_random_port(addr)
    return downstream, port


def bind_control_channel():
    control_channel_sock = context.socket(zmq.REP)
    control_channel_sock.bind('tcp://*:{}'.format(control_channel_port))
    return control_channel_sock


def connect_upstream(topics):
    raw_data = context.socket(zmq.SUB)
    for t in topics:
        raw_data.setsockopt_unicode(zmq.SUBSCRIBE, unicode(t))
    raw_data.connect(upstream_addr)
    return raw_data


if __name__ == '__main__':
    print("Binding control channel socket on {}".format('tcp://*:{}'.format(control_channel_port)))
    control_channel = bind_control_channel()
    while True:
        request = control_channel.recv_json()
        print("Received request {}".format(request))
        if should_grant(request):
            (downstream_sock, downstream_port) = bind_downstream()
            print("Downstream socket open on {}".format('tcp://*:{}'.format(downstream_port)))

            print("Connecting to upstream on {}".format(upstream_addr))
            upstream_sock = connect_upstream(request['topics'])

            control_channel.send_json({'status': 'ok', 'port': downstream_port})
            while True:
                parts = upstream_sock.recv_multipart() # Simple forwarding
                downstream_sock.send_multipart(parts)
        else:
            control_channel.send_json({'status': 'rejected'})

1 个答案:

答案 0 :(得分:1)

从swift 3版开始,Swift标准库包含没有&#NS; NS'的基础框架类。字首;因此,由于您使用的是URLSession而不是NSURLSession,因此必须使用URL而不是NSURL来使这两个类在URLSession实例方法中相互兼容' dataTask(with:completionHandler :)'。

只需将网址声明为

即可
let url = URL(string: profileImageUrl)

并完成。