2012-04-09 12 views
0

辞書の内容の配列がありますが、辞書の値を取得できません。 以下は辞書形式と辞書 "resdata"であり、timestampは辞書のキー値です。だから私はタイムスタンプの値を取得する方法を知る必要があります。iphoneで辞書の値の配列にアクセスする方法

<__NSArrayM 0x89426d0>(
{ 
    resData =  (
       { 

       timestamp = "2012-04-09 13:54:08 +0000"; 

       } 
    ); 
    seqCounter = 101; 
} 


here is the source code 
for (int i = 0; i < [self.gluClkDetailArray count]; i++) 
     { 
      NSMutableDictionary *mDict = [self.gluClkDetailArray objectAtIndex:i]; 
      NSDate *mDate = [[mDict objectForKey:@"resData"] objectForKey:@"timestamp"]; 
      NSLog(@"NSDATE-----%@", mDate); 
     } 

In above code the dictionary value is 0. 

Thanks in advance 

答えて

1

resDataは、辞書の配列です。アレイに

ランキング:

for (NSDictionary *mDict in self.gluClkDetailArray) { 
    NSArray *resData = [mDict objectForKey:@"resData"]; 
    NSString *timestamp = [[resData objectAtIndex:0] objectForKey:@"timestamp"]; 
    NSLog(@"timestamp: %@", timestamp); 
} 

例(LLVM 4.0を有する):

NSArray *a = @[ @{ @"resData" : @[ @{ @"timestamp" : @"2012-04-09 13:54:08 +0000" } ], 
        @"seqCounter" : @101 
       } 
      ]; 
NSLog(@"a: %@", a); 

for (NSDictionary *mDict in a) { 
    NSArray *resData = [mDict objectForKey:@"resData"]; 
    NSString *timestamp = [[resData objectAtIndex:0] objectForKey:@"timestamp"]; 
    NSLog(@"timestamp: %@", timestamp); 
} 

のNSLog出力:

a: (
     { 
     resData =   (
         { 
       timestamp = "2012-04-09 13:54:08 +0000"; 
      } 
     ); 
     seqCounter = 101; 
    } 
) 

タイムスタンプ:2012-04-09 13 :54:08 + 0000

関連する問題