not able print twitter response on label in table view

64 views Asked by At

i am getting twitter v 11 api response and i fill up my array but from that i am not able to print on tableview here is the response

[(Swift.ImplicitlyUnwrappedOptional<Any>.some(<__NSArrayM 0x600000842520>(
{
    contributors = "";
    coordinates = "";
    "created_at" = "Thu Jul 12 11:49:57 +0000 2018";
    entities =     {
        hashtags =         (
        );
        media =         (
                        {
                "display_url" = "pic.twitter.com/IJtq6aLM7K";
                "expanded_url" = "";
                id = 1017375504448479232;
                "id_str" = 1017375504448479232;
                indices =                 (
                    12,
                    35
                );
                "media_url" = "";
                "media_url_https" = "";
                sizes =                 {
                    large =                     {
                        h = 1820;
                        resize = fit;
                        w = 2048;
                    };
                    medium =                     {
                        h = 1067;
                        resize = fit;
                        w = 1200;
                    };
                    small =                     {
                        h = 604;
                        resize = fit;
                        w = 680;
                    };
                    thumb =                     {
                        h = 150;
                        resize = crop;
                        w = 150;
                    };
                };
                type = photo;
                url = "";
            }
        );
        symbols =         (
        );
        urls =         (
        );
        "user_mentions" =         (
        );
    };
    "extended_entities" =     {
        media =         (
                        {
                "display_url" = "pic.twitter.com/IJtq6aLM7K";
                "expanded_url" = "";
                id = 1017375504448479232;
                "id_str" = 1017375504448479232;
                indices =                 (
                    12,
                    35
                );
                "media_url" = "";
                "media_url_https" = "";
                sizes =                 {
                    large =                     {
                        h = 1820;
                        resize = fit;
                        w = 2048;
                    };
                    medium =                     {
                        h = 1067;
                        resize = fit;
                        w = 1200;
                    };
                    small =                     {
                        h = 604;
                        resize = fit;
                        w = 680;
                    };
                    thumb =                     {
                        h = 150;
                        resize = crop;
                        w = 150;
                    };
                };
                type = photo;
                url = "";
            }
        );
    };
    "favorite_count" = 0;
    favorited = 0;
    geo = "";
    id = 1017375507174719488;
    "id_str" = 1017375507174719488;
    "in_reply_to_screen_name" = "";
    "in_reply_to_status_id" = "";
    "in_reply_to_status_id_str" = "";
    "in_reply_to_user_id" = "";
    "in_reply_to_user_id_str" = "";
    "is_quote_status" = 0;
    lang = fr;
    place = "";
    "possibly_sensitive" = 0;
    "retweet_count" = 0;
    retweeted = 0;
    source = "";
    text = "Tweet Tweet";
    truncated = 0;

and here is my code where i fill up my array

from this code i am getting response

var timeline = (FHSTwitterEngine.shared().getTimelineForUser(FHSTwitterEngine.shared().authenticatedUsername, isID: true, count: 10), terminator: "")

and now i fill up my array like this

 var serviceData : [AnyObject]=[]
 let timelinedata = [timeline] as [AnyObject]
        serviceData = (timelinedata)
        print(serviceData)

i am getting whole response in service data now i am trying to print on label in table view like below

let retweerCount = serviceData[indexPath.row]["retweet_count"]
            cell.lblRetweet.text = retweerCount as? String

nut i am not able to print can any one give me solution for this

1

There are 1 answers

5
Chirag Shah On BEST ANSWER

I think retweerCount is in integer not string so use below code.

cell.lblRetweet.text = "\(retweerCount as? Int ?? 0)"