从NSDictionary设置UILabel文本

时间:2014-06-26 16:50:29

标签: ios nsdictionary

我有一个问题。我需要将文本值设置为NSDictionary中的UILabel。

我将文本设置为UILabel的代码是:

Refunds *current = [refunds_view objectAtIndex:indexPath.row];
cell.sol_number.text = [NSString stringWithFormat:@"%@",current.company];

当前是 Refunds.h

 #import <Foundation/Foundation.h>


 @interface Refunds : NSObject

-(id)initWithJSONData:(NSDictionary*)data;

 @property (assign) NSNumber *refunds_id;
 @property (assign) NSNumber *request_number;
 @property (strong) NSString *policy_code;
 @property (strong) NSString *company;

@end

Refunds.m

 #import "Refunds.h"

 @implementation Refunds 

 @synthesize refunds_id;
 @synthesize request_number;
 @synthesize policy_code;
 @synthesize company;
 -(id)initWithJSONData:(NSDictionary*)data{
  self = [super init];
  if(self){
    NSLog(@"initWithJSONData method called ");


   refunds_id =  [data valueForKey:@"id"];
   request_number = [data valueForKey:@"request_number"];
   policy_code = [data valueForKey:@"policy_code"];
   company = [data valueForKey:@"company"];
  }
  return self;
  }
@end

当我尝试将值设置为UILAbel时,没有出现错误但是值不显示完整,只显示(

NSLog(@"%@",[current company]);

//This is the value of [current company]
2014-06-26 10:32:13.917 Benefits[7178:70b] (
Benefits
)

cell.sol_number.text = [NSString stringWithFormat:@"%@", current.company];

对此有任何想法。

感谢。

最诚挚的问候。

1 个答案:

答案 0 :(得分:2)

我认为你需要使用公司价值而不是&#34; date&#34;价值......就像它一样

cell.sol_number.text = [NSString stringWithFormat:@"%@",current.company];