繁体   English   中英

iPhone:如何在UILabel上保留整数值

[英]iPhone: how to keep integer value on UILabel

我正在iPhone的Twitter上工作

现在我必须在UILabel上保留Friend,Tweets,Followers等的计数

如何使用这个

- (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)connectionIdentifier {

        NSLog(@"User Info Received: %@", userInfo);   // userInfo contains all user details like userName, screenName, count of Friends, Followers, Following, Status Count etc 

    NSLog(@"User Info Received: %d", [userInfo count]); 


    NSMutableDictionary *profileData = [userInfo objectAtIndex:0]; //converting userInfo array into profileData dictionary

    lblUserName.text = [profileData objectForKey:@"name"]; // lblUserName is UILabel, userName keeping on Label

       lblLocation.text = [profileData objectForKey:@"location"]; // lblLocation is UILabel, Location keeping on Label

    lblDescription.text = [profileData objectForKey:@"description"]; // lblDescription is UILabel, Location keeping on Label

/////*** Up to here all working but how to Keep integer value on UILabel *****/////

          lblFolCount = (NSNumber *)[profileData objectForKey:@"followers_count"]; //how to keep user Followers Count on UILable 

    lblFavCount = (NSNumber *)[profileData objectForKey:@"favourites_count"]; //how to keep user Followers Count on UILable 

    lblStatusCount = (NSNumber *) [profileData objectForKey:@"statuses_count"]; //how to keep user statuses count on UILable 

    lblFriends = (NSNumber *) [profileData objectForKey:@"friends_count"]; //how to keep user friends count on UILable 

}

////*****This info Display on debugger console****///////
////NSLog(@"User Info Received: %@", userInfo);   // by this we get info on debugger console

收到的用户信息:({

    "created_at" = "Tue Nov 02 14:42:42 +0000 2010";

    description = "being honest";

    favorited = false;

    "favourites_count" = 0;

     "followers_count" = 5;

    "friends_count" = 21;

    "listed_count" = 0;

    location = Chennai;

    name = "nanda kishore reddyv";

       "profile_background_color" = EDECE9;

    "profile_background_image_url" = "http://a2.twimg.com/a/1292975674/images/themes/theme3/bg.gif";

    "profile_background_tile" = false;

    "profile_image_url" = "http://a2.twimg.com/a/1292975674/images/default_profile_6_normal.png";

    "retweet_count" = 0;

    "screen_name" = velugotinanda;

    source = "<a href=\"http://www.icodeblog.com\" rel=\"nofollow\">iCodeBlog Oauth Demo</a>";

    status = "Mon Dec 27 09:22:44 +0000 2010";
    "statuses_count" = 15;

    "time_zone" = "Indiana (East)";

   verified = false;
}

)2011-01-01 10:38:29.460 IdeaTweet [471:207]收到的用户信息:1

谢谢,您能告诉我如何在UILabel上保留整数值

您可以像这样。

lblFolCount = (NSNumber *) [profileData objectForKey:@"followers_count"];
[lblFolc setText:[NSString stringWithFormat:@"%d", [lblFolCount intValue]]];
lblFolCount.text = [NSString stringWithFormat:@"%d", 
                     [[profileData objectForKey:@"followers_count"] intValue]];

这里,

UILabel *lblFolCount;
NSMutableDictionary *profileData;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM