2014-06-26 124 views
1

我有一個問題。我需要從NSDictionary設置文本值到UILabel。從NSDictionary設置UILabel文本

我的代碼來設置文本的UILabel是:

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

WHERE CURRENT是 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]; 

對此有任何想法。

謝謝。

最好的問候。

+0

沒有日期屬性被發現在你的退款類.... – Rohit

+0

對不起,我錯了。我需要設置de UILabel的價值。我需要設置的價值是[當前公司]; @Pfitz –

+0

send me nslog current –

回答

2

我認爲你需要使用公司的價值而不是「日期」 value..just喜歡它

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

是的,但是當顯示列表時,我只能看到這個字符**(** [current company]的值是'//這是[current company]的值 2014-06-26 10:32: 13.917好處[7178:70b]( 好處 )' –

+0

那麼你想要什麼....?你有什麼問題..?你可以解釋一下 – Rohit

+0

嗨@Rohit是的我需要設置值從我的UILabel從NSDictionary和什麼時候設置這個值只能看到這個字符**(**並打印NSLog(@「%@」,[當前公司]),結果是// //這是[當前公司]的價值 2014-06-26 10:32:13.917好處[7178:70b]( 好處 )' –