2

私の問題は、「R real:」の結果が完璧であることですが、たとえば 'cloth.R' を int に変換すると、結果は 0 でした。どうすれば解決できますか。ありがとう。

 Cloth *cloth = [app.clothArray objectAtIndex:0];
NSLog(@"R real:%@",cloth.R);
 NSLog(@"G real:%@",cloth.G);
 NSLog(@"B real:%@",cloth.B);

NSString *aNumberString = cloth.R;
int i = [aNumberString intValue];
NSLog(@"NSString:%@",aNumberString);
NSLog(@"Int:%i",i);

結果:

2013-07-22 18:57:45.965 App_ermenegild[26030:c07] R real:
232
2013-07-22 18:57:45.965 App_ermenegild[26030:c07] G real:
0
2013-07-22 18:57:45.965 App_ermenegild[26030:c07] B real:
121
2013-07-22 18:57:45.966 App_ermenegild[26030:c07] NSString:
232
2013-07-22 18:57:45.966 App_ermenegild[26030:c07] Int:0

編集
ここにClothクラスがあります

@interface Cloth : NSObject 
@property(nonatomic,retain) NSString *nom; 
@property(nonatomic,retain) NSString *R; 
@property(nonatomic,retain) NSString *G; 
@property(nonatomic,retain) NSString *B; 
@property(nonatomic,retain) NSString *col; 
@property (nonatomic,readwrite) NSInteger *clothID; 
@end

ここで XML ファイルのパターン:

<cloth id="1">
<nom>Heliconia</nom>
<R>232</R>
<G>0</G>
<B>121</B>
<col>#E80079</col>
</cloth>
4

2 に答える 2